From cb326357666eb5ee9e40f9630129d9de849debba Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Apr 2022 01:32:06 +0000 Subject: [PATCH 001/135] Auto-generated commit a9c03a7279008dee889be371276b5fc6e0f603c3 --- CONTRIBUTORS | 28 + LICENSE | 481 +++++++++ NOTICE | 1 + README.md | 353 +++++++ index.d.ts | 142 +++ index.mjs | 4 + index.mjs.map | 1 + package.json | 40 + stats.html | 2689 +++++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 3739 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..fdb78ea --- /dev/null +++ b/README.md @@ -0,0 +1,353 @@ + + +# untilEach + +[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] + +> Until a test condition is true, invoke a function for each element in a collection. + + + +
+ +
+ + + + + + + +
+ +## Usage + +```javascript +import untilEach from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-until-each@esm/index.mjs'; +``` + +#### untilEach( collection, predicate, fcn\[, thisArg ] ) + +Invokes a `function` for each element in a `collection` until either a `predicate` function returns `true` or the function has iterated over all `collection` elements. + +```javascript +function predicate( value ) { + return ( value !== value ); +} + +function log( value, index ) { + console.log( '%s: %d', index, value ); +} + +var arr = [ 1, 2, 3, NaN, 4 ]; + +untilEach( arr, predicate, log ); +/* => + 0: 1 + 1: 2 + 2: 3 +*/ +``` + +Both the `predicate` function and the `function` to apply are provided three arguments: + +- `value`: collection element +- `index`: collection index +- `collection`: input collection + +Basic support for dynamic collections is provided. Note, however, that index incrementation is monotonically increasing. + +```javascript +function predicate( value ) { + return ( value !== value ); +} + +function log1( value, index, collection ) { + console.log( '%s: %d', index, value ); + if ( index === collection.length-1 && collection.length < 10 ) { + collection.push( index+2 ); + } +} + +var arr = [ 1, 2, 3, 4 ]; + +untilEach( arr, predicate, log1 ); +/* => + 0: 1 + 1: 2 + 2: 3 + 3: 4 + 4: 5 + 5: 6 + 6: 7 + 7: 8 + 8: 9 + 9: 10 +*/ + +function log2( value, index, collection ) { + console.log( '%s: %d', index, value ); + collection.shift(); +} + +arr = [ 1, 2, 3, 4 ]; + +untilEach( arr, predicate, log2 ); +/* => + 0: 1 + 1: 3 +*/ +``` + +To set the function execution context for the applied function, provide a `thisArg`. + +```javascript +function predicate( value ) { + return ( value !== value ); +} + +function sum( value ) { + this.sum += value; + this.count += 1; +} + +var arr = [ 1, 2, 3, NaN, 4 ]; + +var context = { + 'sum': 0, + 'count': 0 +}; + +untilEach( arr, predicate, sum, context ); + +var mean = context.sum / context.count; +// returns 2.0 +``` + +
+ + + + + +
+ +## Notes + +- A `collection` may be either an [`Array`][mdn-array], [`Typed Array`][mdn-typed-array], or an array-like [`Object`][mdn-object] (excluding `strings` and `functions`). + +- The function returns the input `collection`. + +- The function does **not** skip `undefined` elements. + + + + ```javascript + function predicate( value ) { + return ( value !== value ); + } + + function log( value, index ) { + console.log( '%s: %s', index, value ); + } + + var arr = [ 1, , , 4 ]; + + untilEach( arr, predicate, log ); + /* => + 0: 1 + 1: undefined + 2: undefined + 3: 4 + */ + ``` + +- The function provides limited support for dynamic collections (i.e., collections whose `length` changes during execution). + +
+ + + + + +
+ +## 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..587a492 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,142 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2019 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 2.0 + +/// + +import { Collection } from '@stdlib/types/object'; + +/** +* Checks whether an element in a collection passes a test. +* +* @returns boolean indicating whether an element in a collection passes a test +*/ +type NullaryPredicate = () => boolean; + +/** +* Checks whether an element in a collection passes a test. +* +* @param value - collection value +* @returns boolean indicating whether an element in a collection passes a test +*/ +type UnaryPredicate = ( value: any ) => boolean; + +/** +* Checks whether an element in a collection passes a test. +* +* @param value - collection value +* @param index - collection index +* @returns boolean indicating whether an element in a collection passes a test +*/ +type BinaryPredicate = ( value: any, index: number ) => boolean; + +/** +* Checks whether an element in a collection passes a test. +* +* @param value - collection value +* @param index - collection index +* @param collection - input collection +* @returns boolean indicating whether an element in a collection passes a test +*/ +type TernaryPredicate = ( value: any, index: number, collection: Collection ) => boolean; // tslint-disable-line max-line-length + +/** +* Checks whether an element in a collection passes a test. +* +* @param value - collection value +* @param index - collection index +* @param collection - input collection +* @returns boolean indicating whether an element in a collection passes a test +*/ +type Predicate = NullaryPredicate | UnaryPredicate | BinaryPredicate | TernaryPredicate; // tslint-disable-line max-line-length + +/** +* Function invoked for each collection element until test condition is true. +*/ +type Nullary = () => void; + +/** +* Function invoked for each collection element until test condition is true. +* +* @param value - collection value +*/ +type Unary = ( value: any ) => void; + +/** +* Function invoked for each collection element until test condition is true. +* +* @param value - collection value +* @param index - collection index +*/ +type Binary = ( value: any, index: number ) => void; + +/** +* Function invoked for each collection element until test condition is true. +* +* @param value - collection value +* @param index - collection index +* @param collection - input collection +*/ +type Ternary = ( value: any, index: number, collection: Collection ) => void; + +/** +* Function invoked for each collection element until test condition is true. +* +* @param value - collection value +* @param index - collection index +* @param collection - input collection +*/ +type Callback = Nullary | Unary | Binary | Ternary; + +/** +* Until a test condition is true, invokes a function once for each element in a collection. +* +* ## Notes +* +* - When invoked, both the predicate function and the function to apply are provided three arguments: +* +* - `value`: collection value +* - `index`: collection index +* - `collection`: the input collection +* +* @param collection - input collection +* @param predicate - function which indicates whether to stop iterating over a collection +* @param fcn - function to invoke +* @param thisArg - execution context for the applied function +* @returns input collection +* +* @example +* function predicate( v, key, collection ) { +* return ( v !== v ); +* } +* +* function log( v, key, collection ) { +* console.log( '%s: %d', key, v ); +* } +* +* var arr = [ 1, 2, 3, 4, NaN, 5 ]; +* +* untilEach( arr, predicate, log ); +*/ +declare function untilEach( collection: Collection, predicate: Predicate, fcn: Callback, thisArg?: any ): Collection; // tslint-disable-line max-line-length + + +// EXPORTS // + +export = untilEach; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..764bcd4 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";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/string-format@esm/index.mjs";var n=t,s=e,i=r;var a=function(t,e,r,a){var o,m;if(!n(t))throw new TypeError(i("invalid argument. First argument must be a collection. Value: `%s`.",t));if(!s(e))throw new TypeError(i("invalid argument. Second argument must be a function. Value: `%s`.",e));if(!s(r))throw new TypeError(i("invalid argument. Third argument must be a function. Value: `%s`.",r));for(o=t.length,m=0;m + + + + + + RollUp Visualizer + + + +
+ + + + + From 0e5664ed7fe2287d3460d0fbed19b1e2f6c48a50 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 00:20:16 +0000 Subject: [PATCH 002/135] Transform error messages --- lib/until_each.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/until_each.js b/lib/until_each.js index 846d968..0be8304 100644 --- a/lib/until_each.js +++ b/lib/until_each.js @@ -22,7 +22,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,13 +56,13 @@ function untilEach( collection, predicate, fcn, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); + throw new TypeError( format( '0lxBO', collection ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '0lx2S', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0lx3Z', fcn ) ); } len = collection.length; i = 0; diff --git a/package.json b/package.json index 4116b70..10bba26 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-collection": "^0.0.x", "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From b52cbfcbb2f6f66a8b608a35b44b7a3065c62201 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 06:05:38 +0000 Subject: [PATCH 003/135] Remove files --- index.d.ts | 142 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2836 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 587a492..0000000 --- a/index.d.ts +++ /dev/null @@ -1,142 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Collection } from '@stdlib/types/object'; - -/** -* Checks whether an element in a collection passes a test. -* -* @returns boolean indicating whether an element in a collection passes a test -*/ -type NullaryPredicate = () => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @returns boolean indicating whether an element in a collection passes a test -*/ -type UnaryPredicate = ( value: any ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @returns boolean indicating whether an element in a collection passes a test -*/ -type BinaryPredicate = ( value: any, index: number ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type TernaryPredicate = ( value: any, index: number, collection: Collection ) => boolean; // tslint-disable-line max-line-length - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Predicate = NullaryPredicate | UnaryPredicate | BinaryPredicate | TernaryPredicate; // tslint-disable-line max-line-length - -/** -* Function invoked for each collection element until test condition is true. -*/ -type Nullary = () => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -*/ -type Unary = ( value: any ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -*/ -type Binary = ( value: any, index: number ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Ternary = ( value: any, index: number, collection: Collection ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Until a test condition is true, invokes a function once for each element in a collection. -* -* ## Notes -* -* - When invoked, both the predicate function and the function to apply are provided three arguments: -* -* - `value`: collection value -* - `index`: collection index -* - `collection`: the input collection -* -* @param collection - input collection -* @param predicate - function which indicates whether to stop iterating over a collection -* @param fcn - function to invoke -* @param thisArg - execution context for the applied function -* @returns input collection -* -* @example -* function predicate( v, key, collection ) { -* return ( v !== v ); -* } -* -* function log( v, key, collection ) { -* console.log( '%s: %d', key, v ); -* } -* -* var arr = [ 1, 2, 3, 4, NaN, 5 ]; -* -* untilEach( arr, predicate, log ); -*/ -declare function untilEach( collection: Collection, predicate: Predicate, fcn: Callback, thisArg?: any ): Collection; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = untilEach; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 764bcd4..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";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/string-format@esm/index.mjs";var n=t,s=e,i=r;var a=function(t,e,r,a){var o,m;if(!n(t))throw new TypeError(i("invalid argument. First argument must be a collection. Value: `%s`.",t));if(!s(e))throw new TypeError(i("invalid argument. Second argument must be a function. Value: `%s`.",e));if(!s(r))throw new TypeError(i("invalid argument. Third argument must be a function. Value: `%s`.",r));for(o=t.length,m=0;m - - - - - - RollUp Visualizer - - - -
- - - - - From bc5196b6ea7751d0ac9893e93e2ec119c275fbae Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 06:06:30 +0000 Subject: [PATCH 004/135] 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 | 43 +- benchmark/benchmark.js | 89 - branches.md | 53 - docs/repl.txt | 47 - docs/types/test.ts | 71 - examples/index.js | 53 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/until_each.js | 83 - package.json | 61 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 350 --- 37 files changed, 2715 insertions(+), 3729 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/until_each.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 90b7d06..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-06-30T22:01:02.278Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 038a13c..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/utils/until-each) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f023c60..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/utils/until-each) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -282,7 +275,7 @@ untilEach( arr, predicate, log ); ## 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]. @@ -350,9 +343,9 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right +[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right/tree/esm -[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each +[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 16edfdb..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var untilEach = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var sum; - var i; - - function predicate( v ) { - return isnan( v ); - } - - function fcn( v ) { - sum += v; - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - untilEach( arr, predicate, fcn ); - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::loop', function benchmark( b ) { - var sum; - var arr; - var i; - var j; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - j = 0; - while ( j < arr.length ) { - if ( isnan( arr[ j ] ) ) { - break; - } - sum += arr[ j ]; - j += 1; - } - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2ccf847..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/utils/until-each" -click B href "https://github.com/stdlib-js/utils-until-each/tree/main" -click C href "https://github.com/stdlib-js/utils-until-each/tree/production" -click D href "https://github.com/stdlib-js/utils-until-each/tree/esm" -click E href "https://github.com/stdlib-js/utils-until-each/tree/deno" -click F href "https://github.com/stdlib-js/utils-until-each/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/until-each -[production-url]: https://github.com/stdlib-js/utils-until-each/tree/production -[deno-url]: https://github.com/stdlib-js/utils-until-each/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-until-each/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-until-each/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 11ef9f4..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,47 +0,0 @@ - -{{alias}}( collection, predicate, fcn[, thisArg] ) - Until a test condition is true, invokes a function for each element in a - collection. - - When invoked, both the predicate function and the function to apply are - provided three arguments: - - - `value`: collection value - - `index`: collection index - - `collection`: the input collection - - Parameters - ---------- - collection: Array|TypedArray|Object - Input collection over which to iterate. If provided an object, the - object must be array-like (excluding strings and functions). - - predicate: Function - The predicate function which indicates whether to stop iterating over a - collection. - - fcn: Function - The function to invoke for each element in a collection. - - thisArg: any (optional) - Execution context for the applied function. - - Returns - ------- - out: Array|TypedArray|Object - Input collection. - - Examples - -------- - > function predicate( v ) { return v !== v; }; - > function logger( v, i ) { console.log( '%s: %d', i, v ); }; - > var arr = [ 1, 2, 3, 4, NaN, 5 ]; - > {{alias}}( arr, predicate, logger ) - 0: 1 - 1: 2 - 2: 3 - 3: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 753d0bb..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,71 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 untilEach = require( './index' ); - -const log = ( v: any, index: number ): void => { - console.log( `${index}: ${v}` ); -}; - -const isNotNaN = ( v: number ): boolean => { - return ( v === v ); -}; - -// TESTS // - -// The function returns the input collection... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, log ); // $ExpectType Collection - untilEach( [ -1, 1, 2 ], isNotNaN, log, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - untilEach( 2, isNotNaN, log ); // $ExpectError - untilEach( false, isNotNaN, log ); // $ExpectError - untilEach( true, isNotNaN, log ); // $ExpectError - untilEach( {}, isNotNaN, log ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], 2, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], false, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], true, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], 'abc', log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], {}, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], [], log ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, 2 ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, false ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, true ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, 'abc' ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, {} ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - untilEach(); // $ExpectError - untilEach( [ 1, 2, 3 ] ); // $ExpectError - untilEach( [ 1, 2, 3 ], isNotNaN ); // $ExpectError - untilEach( [ 1, 2, 3 ], isNotNaN, log, {}, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index c41d90c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isEven = require( '@stdlib/assert-is-even' ).isPrimitive; -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var untilEach = require( './../lib' ); - -function predicate( value ) { - return ( value !== value ); -} - -function log( value, index, collection ) { - console.log( '%s: %d', index, value ); - if ( isEven( index ) ) { - collection.shift(); - } else { - collection.push( index+1 ); - } -} - -var arr; -var j; -var i; - -arr = new Array( 100 ); -j = floor( randu()*arr.length ); -for ( i = 0; i < arr.length; i++ ) { - if ( i === j ) { - arr[ i ] = NaN; - } else { - arr[ i ] = i; - } -} - -untilEach( arr, predicate, log ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index f0c7962..587a492 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..54e4218 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";function s(s,o,i,n){var l,d;if(!r(s))throw new TypeError(e("0lxBO",s));if(!t(o))throw new TypeError(e("0lx2S",o));if(!t(i))throw new TypeError(e("0lx3Z",i));for(l=s.length,d=0;d=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..baadcfc --- /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 70a1888..0000000 --- a/test/test.js +++ /dev/null @@ -1,350 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var untilEach = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof untilEach, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {}, - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( value, noop, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a predicate function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a function to invoke', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], noop, value ); - }; - } -}); - -tape( 'if provided an empty collection, the function never invokes a provided function', function test( t ) { - var arr = []; - - function predicate() { - t.fail( 'should not be invoked' ); - } - - function foo() { - t.fail( 'should not be invoked' ); - } - - untilEach( arr, predicate, foo ); - - t.deepEqual( arr, [], 'expected result' ); - t.end(); -}); - -tape( 'the function returns the input collection', function test( t ) { - var arr; - var out; - - function predicate() { - t.pass( 'invoked predicated function' ); - return false; - } - - function foo() { - t.pass( 'invoked provided function' ); - } - - arr = [ 1, 2, 3 ]; - - out = untilEach( arr, predicate, foo ); - - t.strictEqual( out, arr, 'returns input collection' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array)', function test( t ) { - var arr; - var out; - - arr = [ 1, 2, NaN, 3 ]; - out = [ 0, 0, 0, 0 ]; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - untilEach( arr, predicate, copy ); - - t.deepEqual( out, [ 1, 2, 0, 0 ], 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array-like object)', function test( t ) { - var expected; - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = { - 'length': 4, - '0': 1, - '1': 2, - '2': NaN, - '3': 3 - }; - out = { - 'length': 4, - '0': 0, - '1': 0, - '2': 0, - '3': 0 - }; - - untilEach( arr, predicate, copy ); - - expected = { - 'length': 4, - '0': 1, - '1': 2, - '2': 0, - '3': 0 - }; - - t.deepEqual( out, expected, 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (typed array)', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = new Float64Array( [ 1.0, 2.0, NaN, 3.0 ] ); - out = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - untilEach( arr, predicate, copy ); - - t.strictEqual( out[ 0 ], 1.0, 'expected result' ); - t.strictEqual( out[ 1 ], 2.0, 'expected result' ); - t.strictEqual( out[ 2 ], 0.0, 'expected result' ); - t.strictEqual( out[ 3 ], 0.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx; - var arr; - - function predicate( value ) { - return ( value !== value ); - } - - function sum( value ) { - /* eslint-disable no-invalid-this */ - this.sum += value; - this.count += 1; - } - - ctx = { - 'sum': 0, - 'count': 0 - }; - arr = [ 1.0, 2.0, 3.0 ]; - - untilEach( arr, predicate, sum, ctx ); - - t.strictEqual( ctx.sum/ctx.count, 2.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function provides basic support for dynamic arrays', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index, collection ) { - out.push( value ); - if ( index === collection.length-1 && collection.length < 10 ) { - collection.push( index+2 ); - } - } - - arr = [ 1, 2, 3 ]; - out = []; - - untilEach( arr, predicate, copy ); - - t.deepEqual( arr, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.deepEqual( out, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.end(); -}); - -tape( 'the function does not skip empty elements', function test( t ) { - var expected; - var arr; - - function predicate( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - return false; - } - - function verify( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - } - - arr = [ 1, , , 4 ]; // eslint-disable-line no-sparse-arrays - expected = [ 1, void 0, void 0, 4 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); - -tape( 'the function invokes the predicate function and the function to apply with three arguments: value, index, collection', function test( t ) { - var indices; - var values; - var arr; - - function predicate( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - return false; - } - - function verify( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - } - - arr = [ 1, 2, 3, 4 ]; - values = [ 1, 2, 3, 4 ]; - indices = [ 0, 1, 2, 3 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); From f96876d3d142648cf9027c64d1f08183a4491883 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 17:45:01 +0000 Subject: [PATCH 005/135] Transform error messages --- lib/until_each.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/until_each.js b/lib/until_each.js index 846d968..0be8304 100644 --- a/lib/until_each.js +++ b/lib/until_each.js @@ -22,7 +22,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,13 +56,13 @@ function untilEach( collection, predicate, fcn, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); + throw new TypeError( format( '0lxBO', collection ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '0lx2S', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0lx3Z', fcn ) ); } len = collection.length; i = 0; diff --git a/package.json b/package.json index 4116b70..10bba26 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-collection": "^0.0.x", "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From f2b82f71d2fdc31f9b15adf3a908dcf82ea477da Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Jul 2022 02:36:19 +0000 Subject: [PATCH 006/135] Remove files --- index.d.ts | 142 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2836 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 587a492..0000000 --- a/index.d.ts +++ /dev/null @@ -1,142 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Collection } from '@stdlib/types/object'; - -/** -* Checks whether an element in a collection passes a test. -* -* @returns boolean indicating whether an element in a collection passes a test -*/ -type NullaryPredicate = () => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @returns boolean indicating whether an element in a collection passes a test -*/ -type UnaryPredicate = ( value: any ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @returns boolean indicating whether an element in a collection passes a test -*/ -type BinaryPredicate = ( value: any, index: number ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type TernaryPredicate = ( value: any, index: number, collection: Collection ) => boolean; // tslint-disable-line max-line-length - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Predicate = NullaryPredicate | UnaryPredicate | BinaryPredicate | TernaryPredicate; // tslint-disable-line max-line-length - -/** -* Function invoked for each collection element until test condition is true. -*/ -type Nullary = () => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -*/ -type Unary = ( value: any ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -*/ -type Binary = ( value: any, index: number ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Ternary = ( value: any, index: number, collection: Collection ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Until a test condition is true, invokes a function once for each element in a collection. -* -* ## Notes -* -* - When invoked, both the predicate function and the function to apply are provided three arguments: -* -* - `value`: collection value -* - `index`: collection index -* - `collection`: the input collection -* -* @param collection - input collection -* @param predicate - function which indicates whether to stop iterating over a collection -* @param fcn - function to invoke -* @param thisArg - execution context for the applied function -* @returns input collection -* -* @example -* function predicate( v, key, collection ) { -* return ( v !== v ); -* } -* -* function log( v, key, collection ) { -* console.log( '%s: %d', key, v ); -* } -* -* var arr = [ 1, 2, 3, 4, NaN, 5 ]; -* -* untilEach( arr, predicate, log ); -*/ -declare function untilEach( collection: Collection, predicate: Predicate, fcn: Callback, thisArg?: any ): Collection; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = untilEach; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 54e4218..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";function s(s,o,i,n){var l,d;if(!r(s))throw new TypeError(e("0lxBO",s));if(!t(o))throw new TypeError(e("0lx2S",o));if(!t(i))throw new TypeError(e("0lx3Z",i));for(l=s.length,d=0;d - - - - - - RollUp Visualizer - - - -
- - - - - From cf9342e34959272bf9412d6d4473ebcc3f92b849 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Jul 2022 02:37:03 +0000 Subject: [PATCH 007/135] 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 | 43 +- benchmark/benchmark.js | 89 - branches.md | 53 - docs/repl.txt | 47 - docs/types/test.ts | 71 - examples/index.js | 53 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/until_each.js | 83 - package.json | 61 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 350 --- 37 files changed, 2715 insertions(+), 3729 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/until_each.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 ed04cbe..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-07-01T01:07:40.803Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 038a13c..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/utils/until-each) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f023c60..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/utils/until-each) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -282,7 +275,7 @@ untilEach( arr, predicate, log ); ## 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]. @@ -350,9 +343,9 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right +[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right/tree/esm -[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each +[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 16edfdb..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var untilEach = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var sum; - var i; - - function predicate( v ) { - return isnan( v ); - } - - function fcn( v ) { - sum += v; - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - untilEach( arr, predicate, fcn ); - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::loop', function benchmark( b ) { - var sum; - var arr; - var i; - var j; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - j = 0; - while ( j < arr.length ) { - if ( isnan( arr[ j ] ) ) { - break; - } - sum += arr[ j ]; - j += 1; - } - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2ccf847..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/utils/until-each" -click B href "https://github.com/stdlib-js/utils-until-each/tree/main" -click C href "https://github.com/stdlib-js/utils-until-each/tree/production" -click D href "https://github.com/stdlib-js/utils-until-each/tree/esm" -click E href "https://github.com/stdlib-js/utils-until-each/tree/deno" -click F href "https://github.com/stdlib-js/utils-until-each/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/until-each -[production-url]: https://github.com/stdlib-js/utils-until-each/tree/production -[deno-url]: https://github.com/stdlib-js/utils-until-each/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-until-each/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-until-each/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 11ef9f4..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,47 +0,0 @@ - -{{alias}}( collection, predicate, fcn[, thisArg] ) - Until a test condition is true, invokes a function for each element in a - collection. - - When invoked, both the predicate function and the function to apply are - provided three arguments: - - - `value`: collection value - - `index`: collection index - - `collection`: the input collection - - Parameters - ---------- - collection: Array|TypedArray|Object - Input collection over which to iterate. If provided an object, the - object must be array-like (excluding strings and functions). - - predicate: Function - The predicate function which indicates whether to stop iterating over a - collection. - - fcn: Function - The function to invoke for each element in a collection. - - thisArg: any (optional) - Execution context for the applied function. - - Returns - ------- - out: Array|TypedArray|Object - Input collection. - - Examples - -------- - > function predicate( v ) { return v !== v; }; - > function logger( v, i ) { console.log( '%s: %d', i, v ); }; - > var arr = [ 1, 2, 3, 4, NaN, 5 ]; - > {{alias}}( arr, predicate, logger ) - 0: 1 - 1: 2 - 2: 3 - 3: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 753d0bb..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,71 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 untilEach = require( './index' ); - -const log = ( v: any, index: number ): void => { - console.log( `${index}: ${v}` ); -}; - -const isNotNaN = ( v: number ): boolean => { - return ( v === v ); -}; - -// TESTS // - -// The function returns the input collection... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, log ); // $ExpectType Collection - untilEach( [ -1, 1, 2 ], isNotNaN, log, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - untilEach( 2, isNotNaN, log ); // $ExpectError - untilEach( false, isNotNaN, log ); // $ExpectError - untilEach( true, isNotNaN, log ); // $ExpectError - untilEach( {}, isNotNaN, log ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], 2, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], false, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], true, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], 'abc', log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], {}, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], [], log ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, 2 ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, false ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, true ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, 'abc' ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, {} ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - untilEach(); // $ExpectError - untilEach( [ 1, 2, 3 ] ); // $ExpectError - untilEach( [ 1, 2, 3 ], isNotNaN ); // $ExpectError - untilEach( [ 1, 2, 3 ], isNotNaN, log, {}, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index c41d90c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isEven = require( '@stdlib/assert-is-even' ).isPrimitive; -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var untilEach = require( './../lib' ); - -function predicate( value ) { - return ( value !== value ); -} - -function log( value, index, collection ) { - console.log( '%s: %d', index, value ); - if ( isEven( index ) ) { - collection.shift(); - } else { - collection.push( index+1 ); - } -} - -var arr; -var j; -var i; - -arr = new Array( 100 ); -j = floor( randu()*arr.length ); -for ( i = 0; i < arr.length; i++ ) { - if ( i === j ) { - arr[ i ] = NaN; - } else { - arr[ i ] = i; - } -} - -untilEach( arr, predicate, log ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index f0c7962..587a492 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..54e4218 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";function s(s,o,i,n){var l,d;if(!r(s))throw new TypeError(e("0lxBO",s));if(!t(o))throw new TypeError(e("0lx2S",o));if(!t(i))throw new TypeError(e("0lx3Z",i));for(l=s.length,d=0;d=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..7a3d3aa --- /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 70a1888..0000000 --- a/test/test.js +++ /dev/null @@ -1,350 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var untilEach = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof untilEach, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {}, - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( value, noop, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a predicate function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a function to invoke', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], noop, value ); - }; - } -}); - -tape( 'if provided an empty collection, the function never invokes a provided function', function test( t ) { - var arr = []; - - function predicate() { - t.fail( 'should not be invoked' ); - } - - function foo() { - t.fail( 'should not be invoked' ); - } - - untilEach( arr, predicate, foo ); - - t.deepEqual( arr, [], 'expected result' ); - t.end(); -}); - -tape( 'the function returns the input collection', function test( t ) { - var arr; - var out; - - function predicate() { - t.pass( 'invoked predicated function' ); - return false; - } - - function foo() { - t.pass( 'invoked provided function' ); - } - - arr = [ 1, 2, 3 ]; - - out = untilEach( arr, predicate, foo ); - - t.strictEqual( out, arr, 'returns input collection' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array)', function test( t ) { - var arr; - var out; - - arr = [ 1, 2, NaN, 3 ]; - out = [ 0, 0, 0, 0 ]; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - untilEach( arr, predicate, copy ); - - t.deepEqual( out, [ 1, 2, 0, 0 ], 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array-like object)', function test( t ) { - var expected; - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = { - 'length': 4, - '0': 1, - '1': 2, - '2': NaN, - '3': 3 - }; - out = { - 'length': 4, - '0': 0, - '1': 0, - '2': 0, - '3': 0 - }; - - untilEach( arr, predicate, copy ); - - expected = { - 'length': 4, - '0': 1, - '1': 2, - '2': 0, - '3': 0 - }; - - t.deepEqual( out, expected, 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (typed array)', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = new Float64Array( [ 1.0, 2.0, NaN, 3.0 ] ); - out = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - untilEach( arr, predicate, copy ); - - t.strictEqual( out[ 0 ], 1.0, 'expected result' ); - t.strictEqual( out[ 1 ], 2.0, 'expected result' ); - t.strictEqual( out[ 2 ], 0.0, 'expected result' ); - t.strictEqual( out[ 3 ], 0.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx; - var arr; - - function predicate( value ) { - return ( value !== value ); - } - - function sum( value ) { - /* eslint-disable no-invalid-this */ - this.sum += value; - this.count += 1; - } - - ctx = { - 'sum': 0, - 'count': 0 - }; - arr = [ 1.0, 2.0, 3.0 ]; - - untilEach( arr, predicate, sum, ctx ); - - t.strictEqual( ctx.sum/ctx.count, 2.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function provides basic support for dynamic arrays', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index, collection ) { - out.push( value ); - if ( index === collection.length-1 && collection.length < 10 ) { - collection.push( index+2 ); - } - } - - arr = [ 1, 2, 3 ]; - out = []; - - untilEach( arr, predicate, copy ); - - t.deepEqual( arr, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.deepEqual( out, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.end(); -}); - -tape( 'the function does not skip empty elements', function test( t ) { - var expected; - var arr; - - function predicate( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - return false; - } - - function verify( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - } - - arr = [ 1, , , 4 ]; // eslint-disable-line no-sparse-arrays - expected = [ 1, void 0, void 0, 4 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); - -tape( 'the function invokes the predicate function and the function to apply with three arguments: value, index, collection', function test( t ) { - var indices; - var values; - var arr; - - function predicate( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - return false; - } - - function verify( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - } - - arr = [ 1, 2, 3, 4 ]; - values = [ 1, 2, 3, 4 ]; - indices = [ 0, 1, 2, 3 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); From e2065a273de5b5461007af6485214b7dc5cc0009 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 5 Jul 2022 12:52:22 +0000 Subject: [PATCH 008/135] Transform error messages --- lib/until_each.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/until_each.js b/lib/until_each.js index 846d968..0be8304 100644 --- a/lib/until_each.js +++ b/lib/until_each.js @@ -22,7 +22,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,13 +56,13 @@ function untilEach( collection, predicate, fcn, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); + throw new TypeError( format( '0lxBO', collection ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '0lx2S', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0lx3Z', fcn ) ); } len = collection.length; i = 0; diff --git a/package.json b/package.json index 4116b70..10bba26 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-collection": "^0.0.x", "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From d4daafc9050df5d204df8fff555651dc958f651b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 5 Jul 2022 13:32:22 +0000 Subject: [PATCH 009/135] Remove files --- index.d.ts | 142 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2836 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 587a492..0000000 --- a/index.d.ts +++ /dev/null @@ -1,142 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Collection } from '@stdlib/types/object'; - -/** -* Checks whether an element in a collection passes a test. -* -* @returns boolean indicating whether an element in a collection passes a test -*/ -type NullaryPredicate = () => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @returns boolean indicating whether an element in a collection passes a test -*/ -type UnaryPredicate = ( value: any ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @returns boolean indicating whether an element in a collection passes a test -*/ -type BinaryPredicate = ( value: any, index: number ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type TernaryPredicate = ( value: any, index: number, collection: Collection ) => boolean; // tslint-disable-line max-line-length - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Predicate = NullaryPredicate | UnaryPredicate | BinaryPredicate | TernaryPredicate; // tslint-disable-line max-line-length - -/** -* Function invoked for each collection element until test condition is true. -*/ -type Nullary = () => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -*/ -type Unary = ( value: any ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -*/ -type Binary = ( value: any, index: number ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Ternary = ( value: any, index: number, collection: Collection ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Until a test condition is true, invokes a function once for each element in a collection. -* -* ## Notes -* -* - When invoked, both the predicate function and the function to apply are provided three arguments: -* -* - `value`: collection value -* - `index`: collection index -* - `collection`: the input collection -* -* @param collection - input collection -* @param predicate - function which indicates whether to stop iterating over a collection -* @param fcn - function to invoke -* @param thisArg - execution context for the applied function -* @returns input collection -* -* @example -* function predicate( v, key, collection ) { -* return ( v !== v ); -* } -* -* function log( v, key, collection ) { -* console.log( '%s: %d', key, v ); -* } -* -* var arr = [ 1, 2, 3, 4, NaN, 5 ]; -* -* untilEach( arr, predicate, log ); -*/ -declare function untilEach( collection: Collection, predicate: Predicate, fcn: Callback, thisArg?: any ): Collection; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = untilEach; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 54e4218..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";function s(s,o,i,n){var l,d;if(!r(s))throw new TypeError(e("0lxBO",s));if(!t(o))throw new TypeError(e("0lx2S",o));if(!t(i))throw new TypeError(e("0lx3Z",i));for(l=s.length,d=0;d - - - - - - RollUp Visualizer - - - -
- - - - - From 24423d12c4b0ab4b32e77abb10ab62f2540ba778 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 5 Jul 2022 13:33:15 +0000 Subject: [PATCH 010/135] 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 | 43 +- benchmark/benchmark.js | 89 - branches.md | 53 - docs/repl.txt | 47 - docs/types/test.ts | 71 - examples/index.js | 53 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/until_each.js | 83 - package.json | 61 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 350 --- 36 files changed, 2715 insertions(+), 3694 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/until_each.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 038a13c..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/utils/until-each) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f023c60..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/utils/until-each) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -282,7 +275,7 @@ untilEach( arr, predicate, log ); ## 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]. @@ -350,9 +343,9 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right +[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right/tree/esm -[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each +[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 16edfdb..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var untilEach = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var sum; - var i; - - function predicate( v ) { - return isnan( v ); - } - - function fcn( v ) { - sum += v; - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - untilEach( arr, predicate, fcn ); - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::loop', function benchmark( b ) { - var sum; - var arr; - var i; - var j; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - j = 0; - while ( j < arr.length ) { - if ( isnan( arr[ j ] ) ) { - break; - } - sum += arr[ j ]; - j += 1; - } - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2ccf847..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/utils/until-each" -click B href "https://github.com/stdlib-js/utils-until-each/tree/main" -click C href "https://github.com/stdlib-js/utils-until-each/tree/production" -click D href "https://github.com/stdlib-js/utils-until-each/tree/esm" -click E href "https://github.com/stdlib-js/utils-until-each/tree/deno" -click F href "https://github.com/stdlib-js/utils-until-each/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/until-each -[production-url]: https://github.com/stdlib-js/utils-until-each/tree/production -[deno-url]: https://github.com/stdlib-js/utils-until-each/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-until-each/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-until-each/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 11ef9f4..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,47 +0,0 @@ - -{{alias}}( collection, predicate, fcn[, thisArg] ) - Until a test condition is true, invokes a function for each element in a - collection. - - When invoked, both the predicate function and the function to apply are - provided three arguments: - - - `value`: collection value - - `index`: collection index - - `collection`: the input collection - - Parameters - ---------- - collection: Array|TypedArray|Object - Input collection over which to iterate. If provided an object, the - object must be array-like (excluding strings and functions). - - predicate: Function - The predicate function which indicates whether to stop iterating over a - collection. - - fcn: Function - The function to invoke for each element in a collection. - - thisArg: any (optional) - Execution context for the applied function. - - Returns - ------- - out: Array|TypedArray|Object - Input collection. - - Examples - -------- - > function predicate( v ) { return v !== v; }; - > function logger( v, i ) { console.log( '%s: %d', i, v ); }; - > var arr = [ 1, 2, 3, 4, NaN, 5 ]; - > {{alias}}( arr, predicate, logger ) - 0: 1 - 1: 2 - 2: 3 - 3: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 753d0bb..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,71 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 untilEach = require( './index' ); - -const log = ( v: any, index: number ): void => { - console.log( `${index}: ${v}` ); -}; - -const isNotNaN = ( v: number ): boolean => { - return ( v === v ); -}; - -// TESTS // - -// The function returns the input collection... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, log ); // $ExpectType Collection - untilEach( [ -1, 1, 2 ], isNotNaN, log, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - untilEach( 2, isNotNaN, log ); // $ExpectError - untilEach( false, isNotNaN, log ); // $ExpectError - untilEach( true, isNotNaN, log ); // $ExpectError - untilEach( {}, isNotNaN, log ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], 2, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], false, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], true, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], 'abc', log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], {}, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], [], log ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, 2 ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, false ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, true ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, 'abc' ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, {} ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - untilEach(); // $ExpectError - untilEach( [ 1, 2, 3 ] ); // $ExpectError - untilEach( [ 1, 2, 3 ], isNotNaN ); // $ExpectError - untilEach( [ 1, 2, 3 ], isNotNaN, log, {}, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index c41d90c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isEven = require( '@stdlib/assert-is-even' ).isPrimitive; -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var untilEach = require( './../lib' ); - -function predicate( value ) { - return ( value !== value ); -} - -function log( value, index, collection ) { - console.log( '%s: %d', index, value ); - if ( isEven( index ) ) { - collection.shift(); - } else { - collection.push( index+1 ); - } -} - -var arr; -var j; -var i; - -arr = new Array( 100 ); -j = floor( randu()*arr.length ); -for ( i = 0; i < arr.length; i++ ) { - if ( i === j ) { - arr[ i ] = NaN; - } else { - arr[ i ] = i; - } -} - -untilEach( arr, predicate, log ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index f0c7962..587a492 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..54e4218 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";function s(s,o,i,n){var l,d;if(!r(s))throw new TypeError(e("0lxBO",s));if(!t(o))throw new TypeError(e("0lx2S",o));if(!t(i))throw new TypeError(e("0lx3Z",i));for(l=s.length,d=0;d=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..ce4f104 --- /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 70a1888..0000000 --- a/test/test.js +++ /dev/null @@ -1,350 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var untilEach = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof untilEach, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {}, - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( value, noop, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a predicate function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a function to invoke', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], noop, value ); - }; - } -}); - -tape( 'if provided an empty collection, the function never invokes a provided function', function test( t ) { - var arr = []; - - function predicate() { - t.fail( 'should not be invoked' ); - } - - function foo() { - t.fail( 'should not be invoked' ); - } - - untilEach( arr, predicate, foo ); - - t.deepEqual( arr, [], 'expected result' ); - t.end(); -}); - -tape( 'the function returns the input collection', function test( t ) { - var arr; - var out; - - function predicate() { - t.pass( 'invoked predicated function' ); - return false; - } - - function foo() { - t.pass( 'invoked provided function' ); - } - - arr = [ 1, 2, 3 ]; - - out = untilEach( arr, predicate, foo ); - - t.strictEqual( out, arr, 'returns input collection' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array)', function test( t ) { - var arr; - var out; - - arr = [ 1, 2, NaN, 3 ]; - out = [ 0, 0, 0, 0 ]; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - untilEach( arr, predicate, copy ); - - t.deepEqual( out, [ 1, 2, 0, 0 ], 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array-like object)', function test( t ) { - var expected; - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = { - 'length': 4, - '0': 1, - '1': 2, - '2': NaN, - '3': 3 - }; - out = { - 'length': 4, - '0': 0, - '1': 0, - '2': 0, - '3': 0 - }; - - untilEach( arr, predicate, copy ); - - expected = { - 'length': 4, - '0': 1, - '1': 2, - '2': 0, - '3': 0 - }; - - t.deepEqual( out, expected, 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (typed array)', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = new Float64Array( [ 1.0, 2.0, NaN, 3.0 ] ); - out = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - untilEach( arr, predicate, copy ); - - t.strictEqual( out[ 0 ], 1.0, 'expected result' ); - t.strictEqual( out[ 1 ], 2.0, 'expected result' ); - t.strictEqual( out[ 2 ], 0.0, 'expected result' ); - t.strictEqual( out[ 3 ], 0.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx; - var arr; - - function predicate( value ) { - return ( value !== value ); - } - - function sum( value ) { - /* eslint-disable no-invalid-this */ - this.sum += value; - this.count += 1; - } - - ctx = { - 'sum': 0, - 'count': 0 - }; - arr = [ 1.0, 2.0, 3.0 ]; - - untilEach( arr, predicate, sum, ctx ); - - t.strictEqual( ctx.sum/ctx.count, 2.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function provides basic support for dynamic arrays', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index, collection ) { - out.push( value ); - if ( index === collection.length-1 && collection.length < 10 ) { - collection.push( index+2 ); - } - } - - arr = [ 1, 2, 3 ]; - out = []; - - untilEach( arr, predicate, copy ); - - t.deepEqual( arr, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.deepEqual( out, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.end(); -}); - -tape( 'the function does not skip empty elements', function test( t ) { - var expected; - var arr; - - function predicate( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - return false; - } - - function verify( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - } - - arr = [ 1, , , 4 ]; // eslint-disable-line no-sparse-arrays - expected = [ 1, void 0, void 0, 4 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); - -tape( 'the function invokes the predicate function and the function to apply with three arguments: value, index, collection', function test( t ) { - var indices; - var values; - var arr; - - function predicate( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - return false; - } - - function verify( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - } - - arr = [ 1, 2, 3, 4 ]; - values = [ 1, 2, 3, 4 ]; - indices = [ 0, 1, 2, 3 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); From 9961f7eac721828802d2b9dcefc7d172d0759541 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 03:43:48 +0000 Subject: [PATCH 011/135] Transform error messages --- lib/until_each.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/until_each.js b/lib/until_each.js index 846d968..0be8304 100644 --- a/lib/until_each.js +++ b/lib/until_each.js @@ -22,7 +22,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,13 +56,13 @@ function untilEach( collection, predicate, fcn, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); + throw new TypeError( format( '0lxBO', collection ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '0lx2S', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0lx3Z', fcn ) ); } len = collection.length; i = 0; diff --git a/package.json b/package.json index 4116b70..10bba26 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-collection": "^0.0.x", "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From 3a496f8af2b251a822a059dafed3e56739f6c9cf Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 17:33:30 +0000 Subject: [PATCH 012/135] Remove files --- index.d.ts | 142 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2836 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 587a492..0000000 --- a/index.d.ts +++ /dev/null @@ -1,142 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Collection } from '@stdlib/types/object'; - -/** -* Checks whether an element in a collection passes a test. -* -* @returns boolean indicating whether an element in a collection passes a test -*/ -type NullaryPredicate = () => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @returns boolean indicating whether an element in a collection passes a test -*/ -type UnaryPredicate = ( value: any ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @returns boolean indicating whether an element in a collection passes a test -*/ -type BinaryPredicate = ( value: any, index: number ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type TernaryPredicate = ( value: any, index: number, collection: Collection ) => boolean; // tslint-disable-line max-line-length - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Predicate = NullaryPredicate | UnaryPredicate | BinaryPredicate | TernaryPredicate; // tslint-disable-line max-line-length - -/** -* Function invoked for each collection element until test condition is true. -*/ -type Nullary = () => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -*/ -type Unary = ( value: any ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -*/ -type Binary = ( value: any, index: number ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Ternary = ( value: any, index: number, collection: Collection ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Until a test condition is true, invokes a function once for each element in a collection. -* -* ## Notes -* -* - When invoked, both the predicate function and the function to apply are provided three arguments: -* -* - `value`: collection value -* - `index`: collection index -* - `collection`: the input collection -* -* @param collection - input collection -* @param predicate - function which indicates whether to stop iterating over a collection -* @param fcn - function to invoke -* @param thisArg - execution context for the applied function -* @returns input collection -* -* @example -* function predicate( v, key, collection ) { -* return ( v !== v ); -* } -* -* function log( v, key, collection ) { -* console.log( '%s: %d', key, v ); -* } -* -* var arr = [ 1, 2, 3, 4, NaN, 5 ]; -* -* untilEach( arr, predicate, log ); -*/ -declare function untilEach( collection: Collection, predicate: Predicate, fcn: Callback, thisArg?: any ): Collection; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = untilEach; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 54e4218..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";function s(s,o,i,n){var l,d;if(!r(s))throw new TypeError(e("0lxBO",s));if(!t(o))throw new TypeError(e("0lx2S",o));if(!t(i))throw new TypeError(e("0lx3Z",i));for(l=s.length,d=0;d - - - - - - RollUp Visualizer - - - -
- - - - - From 71ab53abcbd92c8aa4951d4fec634f1fdace4f2d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 17:34:33 +0000 Subject: [PATCH 013/135] 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 | 43 +- benchmark/benchmark.js | 89 - branches.md | 53 - docs/repl.txt | 47 - docs/types/test.ts | 71 - examples/index.js | 53 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/until_each.js | 83 - package.json | 61 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 350 --- 37 files changed, 2715 insertions(+), 3768 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/until_each.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 e1646ce..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-08-01T01:10:54.388Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 038a13c..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/utils/until-each) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f023c60..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/utils/until-each) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -282,7 +275,7 @@ untilEach( arr, predicate, log ); ## 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]. @@ -350,9 +343,9 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right +[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right/tree/esm -[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each +[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 16edfdb..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var untilEach = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var sum; - var i; - - function predicate( v ) { - return isnan( v ); - } - - function fcn( v ) { - sum += v; - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - untilEach( arr, predicate, fcn ); - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::loop', function benchmark( b ) { - var sum; - var arr; - var i; - var j; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - j = 0; - while ( j < arr.length ) { - if ( isnan( arr[ j ] ) ) { - break; - } - sum += arr[ j ]; - j += 1; - } - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2ccf847..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/utils/until-each" -click B href "https://github.com/stdlib-js/utils-until-each/tree/main" -click C href "https://github.com/stdlib-js/utils-until-each/tree/production" -click D href "https://github.com/stdlib-js/utils-until-each/tree/esm" -click E href "https://github.com/stdlib-js/utils-until-each/tree/deno" -click F href "https://github.com/stdlib-js/utils-until-each/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/until-each -[production-url]: https://github.com/stdlib-js/utils-until-each/tree/production -[deno-url]: https://github.com/stdlib-js/utils-until-each/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-until-each/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-until-each/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 11ef9f4..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,47 +0,0 @@ - -{{alias}}( collection, predicate, fcn[, thisArg] ) - Until a test condition is true, invokes a function for each element in a - collection. - - When invoked, both the predicate function and the function to apply are - provided three arguments: - - - `value`: collection value - - `index`: collection index - - `collection`: the input collection - - Parameters - ---------- - collection: Array|TypedArray|Object - Input collection over which to iterate. If provided an object, the - object must be array-like (excluding strings and functions). - - predicate: Function - The predicate function which indicates whether to stop iterating over a - collection. - - fcn: Function - The function to invoke for each element in a collection. - - thisArg: any (optional) - Execution context for the applied function. - - Returns - ------- - out: Array|TypedArray|Object - Input collection. - - Examples - -------- - > function predicate( v ) { return v !== v; }; - > function logger( v, i ) { console.log( '%s: %d', i, v ); }; - > var arr = [ 1, 2, 3, 4, NaN, 5 ]; - > {{alias}}( arr, predicate, logger ) - 0: 1 - 1: 2 - 2: 3 - 3: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 753d0bb..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,71 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 untilEach = require( './index' ); - -const log = ( v: any, index: number ): void => { - console.log( `${index}: ${v}` ); -}; - -const isNotNaN = ( v: number ): boolean => { - return ( v === v ); -}; - -// TESTS // - -// The function returns the input collection... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, log ); // $ExpectType Collection - untilEach( [ -1, 1, 2 ], isNotNaN, log, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - untilEach( 2, isNotNaN, log ); // $ExpectError - untilEach( false, isNotNaN, log ); // $ExpectError - untilEach( true, isNotNaN, log ); // $ExpectError - untilEach( {}, isNotNaN, log ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], 2, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], false, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], true, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], 'abc', log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], {}, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], [], log ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, 2 ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, false ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, true ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, 'abc' ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, {} ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - untilEach(); // $ExpectError - untilEach( [ 1, 2, 3 ] ); // $ExpectError - untilEach( [ 1, 2, 3 ], isNotNaN ); // $ExpectError - untilEach( [ 1, 2, 3 ], isNotNaN, log, {}, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index c41d90c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isEven = require( '@stdlib/assert-is-even' ).isPrimitive; -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var untilEach = require( './../lib' ); - -function predicate( value ) { - return ( value !== value ); -} - -function log( value, index, collection ) { - console.log( '%s: %d', index, value ); - if ( isEven( index ) ) { - collection.shift(); - } else { - collection.push( index+1 ); - } -} - -var arr; -var j; -var i; - -arr = new Array( 100 ); -j = floor( randu()*arr.length ); -for ( i = 0; i < arr.length; i++ ) { - if ( i === j ) { - arr[ i ] = NaN; - } else { - arr[ i ] = i; - } -} - -untilEach( arr, predicate, log ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index f0c7962..587a492 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..42fa034 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s,o,i,n){var l,d;if(!r(s))throw new TypeError(e("0lxBO",s));if(!t(o))throw new TypeError(e("0lx2S",o));if(!t(i))throw new TypeError(e("0lx3Z",i));for(l=s.length,d=0;d=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..bfa0e52 --- /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 70a1888..0000000 --- a/test/test.js +++ /dev/null @@ -1,350 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var untilEach = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof untilEach, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {}, - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( value, noop, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a predicate function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a function to invoke', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], noop, value ); - }; - } -}); - -tape( 'if provided an empty collection, the function never invokes a provided function', function test( t ) { - var arr = []; - - function predicate() { - t.fail( 'should not be invoked' ); - } - - function foo() { - t.fail( 'should not be invoked' ); - } - - untilEach( arr, predicate, foo ); - - t.deepEqual( arr, [], 'expected result' ); - t.end(); -}); - -tape( 'the function returns the input collection', function test( t ) { - var arr; - var out; - - function predicate() { - t.pass( 'invoked predicated function' ); - return false; - } - - function foo() { - t.pass( 'invoked provided function' ); - } - - arr = [ 1, 2, 3 ]; - - out = untilEach( arr, predicate, foo ); - - t.strictEqual( out, arr, 'returns input collection' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array)', function test( t ) { - var arr; - var out; - - arr = [ 1, 2, NaN, 3 ]; - out = [ 0, 0, 0, 0 ]; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - untilEach( arr, predicate, copy ); - - t.deepEqual( out, [ 1, 2, 0, 0 ], 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array-like object)', function test( t ) { - var expected; - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = { - 'length': 4, - '0': 1, - '1': 2, - '2': NaN, - '3': 3 - }; - out = { - 'length': 4, - '0': 0, - '1': 0, - '2': 0, - '3': 0 - }; - - untilEach( arr, predicate, copy ); - - expected = { - 'length': 4, - '0': 1, - '1': 2, - '2': 0, - '3': 0 - }; - - t.deepEqual( out, expected, 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (typed array)', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = new Float64Array( [ 1.0, 2.0, NaN, 3.0 ] ); - out = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - untilEach( arr, predicate, copy ); - - t.strictEqual( out[ 0 ], 1.0, 'expected result' ); - t.strictEqual( out[ 1 ], 2.0, 'expected result' ); - t.strictEqual( out[ 2 ], 0.0, 'expected result' ); - t.strictEqual( out[ 3 ], 0.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx; - var arr; - - function predicate( value ) { - return ( value !== value ); - } - - function sum( value ) { - /* eslint-disable no-invalid-this */ - this.sum += value; - this.count += 1; - } - - ctx = { - 'sum': 0, - 'count': 0 - }; - arr = [ 1.0, 2.0, 3.0 ]; - - untilEach( arr, predicate, sum, ctx ); - - t.strictEqual( ctx.sum/ctx.count, 2.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function provides basic support for dynamic arrays', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index, collection ) { - out.push( value ); - if ( index === collection.length-1 && collection.length < 10 ) { - collection.push( index+2 ); - } - } - - arr = [ 1, 2, 3 ]; - out = []; - - untilEach( arr, predicate, copy ); - - t.deepEqual( arr, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.deepEqual( out, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.end(); -}); - -tape( 'the function does not skip empty elements', function test( t ) { - var expected; - var arr; - - function predicate( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - return false; - } - - function verify( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - } - - arr = [ 1, , , 4 ]; // eslint-disable-line no-sparse-arrays - expected = [ 1, void 0, void 0, 4 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); - -tape( 'the function invokes the predicate function and the function to apply with three arguments: value, index, collection', function test( t ) { - var indices; - var values; - var arr; - - function predicate( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - return false; - } - - function verify( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - } - - arr = [ 1, 2, 3, 4 ]; - values = [ 1, 2, 3, 4 ]; - indices = [ 0, 1, 2, 3 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); From 864874d16c3cca795bce4873ba6121b555c11036 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 03:34:51 +0000 Subject: [PATCH 014/135] Transform error messages --- lib/until_each.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/until_each.js b/lib/until_each.js index 846d968..0be8304 100644 --- a/lib/until_each.js +++ b/lib/until_each.js @@ -22,7 +22,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,13 +56,13 @@ function untilEach( collection, predicate, fcn, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); + throw new TypeError( format( '0lxBO', collection ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '0lx2S', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0lx3Z', fcn ) ); } len = collection.length; i = 0; diff --git a/package.json b/package.json index 4116b70..10bba26 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-collection": "^0.0.x", "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From 3d439028dbe381b51c36da2079a492f9427db576 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 10:45:11 +0000 Subject: [PATCH 015/135] Remove files --- index.d.ts | 142 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2836 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 587a492..0000000 --- a/index.d.ts +++ /dev/null @@ -1,142 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Collection } from '@stdlib/types/object'; - -/** -* Checks whether an element in a collection passes a test. -* -* @returns boolean indicating whether an element in a collection passes a test -*/ -type NullaryPredicate = () => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @returns boolean indicating whether an element in a collection passes a test -*/ -type UnaryPredicate = ( value: any ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @returns boolean indicating whether an element in a collection passes a test -*/ -type BinaryPredicate = ( value: any, index: number ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type TernaryPredicate = ( value: any, index: number, collection: Collection ) => boolean; // tslint-disable-line max-line-length - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Predicate = NullaryPredicate | UnaryPredicate | BinaryPredicate | TernaryPredicate; // tslint-disable-line max-line-length - -/** -* Function invoked for each collection element until test condition is true. -*/ -type Nullary = () => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -*/ -type Unary = ( value: any ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -*/ -type Binary = ( value: any, index: number ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Ternary = ( value: any, index: number, collection: Collection ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Until a test condition is true, invokes a function once for each element in a collection. -* -* ## Notes -* -* - When invoked, both the predicate function and the function to apply are provided three arguments: -* -* - `value`: collection value -* - `index`: collection index -* - `collection`: the input collection -* -* @param collection - input collection -* @param predicate - function which indicates whether to stop iterating over a collection -* @param fcn - function to invoke -* @param thisArg - execution context for the applied function -* @returns input collection -* -* @example -* function predicate( v, key, collection ) { -* return ( v !== v ); -* } -* -* function log( v, key, collection ) { -* console.log( '%s: %d', key, v ); -* } -* -* var arr = [ 1, 2, 3, 4, NaN, 5 ]; -* -* untilEach( arr, predicate, log ); -*/ -declare function untilEach( collection: Collection, predicate: Predicate, fcn: Callback, thisArg?: any ): Collection; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = untilEach; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 42fa034..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s,o,i,n){var l,d;if(!r(s))throw new TypeError(e("0lxBO",s));if(!t(o))throw new TypeError(e("0lx2S",o));if(!t(i))throw new TypeError(e("0lx3Z",i));for(l=s.length,d=0;d - - - - - - RollUp Visualizer - - - -
- - - - - From 261f4a563a4278837138112f2b76e4693696dc5f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 10:45:57 +0000 Subject: [PATCH 016/135] 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 | 43 +- benchmark/benchmark.js | 89 - branches.md | 53 - docs/repl.txt | 47 - docs/types/test.ts | 71 - examples/index.js | 53 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/until_each.js | 83 - package.json | 61 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 350 --- 37 files changed, 2715 insertions(+), 3784 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/until_each.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 7ec01c6..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-09-01T01:08:37.008Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 038a13c..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/utils/until-each) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f023c60..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/utils/until-each) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -282,7 +275,7 @@ untilEach( arr, predicate, log ); ## 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]. @@ -350,9 +343,9 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right +[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right/tree/esm -[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each +[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 16edfdb..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var untilEach = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var sum; - var i; - - function predicate( v ) { - return isnan( v ); - } - - function fcn( v ) { - sum += v; - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - untilEach( arr, predicate, fcn ); - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::loop', function benchmark( b ) { - var sum; - var arr; - var i; - var j; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - j = 0; - while ( j < arr.length ) { - if ( isnan( arr[ j ] ) ) { - break; - } - sum += arr[ j ]; - j += 1; - } - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2ccf847..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/utils/until-each" -click B href "https://github.com/stdlib-js/utils-until-each/tree/main" -click C href "https://github.com/stdlib-js/utils-until-each/tree/production" -click D href "https://github.com/stdlib-js/utils-until-each/tree/esm" -click E href "https://github.com/stdlib-js/utils-until-each/tree/deno" -click F href "https://github.com/stdlib-js/utils-until-each/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/until-each -[production-url]: https://github.com/stdlib-js/utils-until-each/tree/production -[deno-url]: https://github.com/stdlib-js/utils-until-each/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-until-each/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-until-each/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 11ef9f4..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,47 +0,0 @@ - -{{alias}}( collection, predicate, fcn[, thisArg] ) - Until a test condition is true, invokes a function for each element in a - collection. - - When invoked, both the predicate function and the function to apply are - provided three arguments: - - - `value`: collection value - - `index`: collection index - - `collection`: the input collection - - Parameters - ---------- - collection: Array|TypedArray|Object - Input collection over which to iterate. If provided an object, the - object must be array-like (excluding strings and functions). - - predicate: Function - The predicate function which indicates whether to stop iterating over a - collection. - - fcn: Function - The function to invoke for each element in a collection. - - thisArg: any (optional) - Execution context for the applied function. - - Returns - ------- - out: Array|TypedArray|Object - Input collection. - - Examples - -------- - > function predicate( v ) { return v !== v; }; - > function logger( v, i ) { console.log( '%s: %d', i, v ); }; - > var arr = [ 1, 2, 3, 4, NaN, 5 ]; - > {{alias}}( arr, predicate, logger ) - 0: 1 - 1: 2 - 2: 3 - 3: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 753d0bb..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,71 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 untilEach = require( './index' ); - -const log = ( v: any, index: number ): void => { - console.log( `${index}: ${v}` ); -}; - -const isNotNaN = ( v: number ): boolean => { - return ( v === v ); -}; - -// TESTS // - -// The function returns the input collection... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, log ); // $ExpectType Collection - untilEach( [ -1, 1, 2 ], isNotNaN, log, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - untilEach( 2, isNotNaN, log ); // $ExpectError - untilEach( false, isNotNaN, log ); // $ExpectError - untilEach( true, isNotNaN, log ); // $ExpectError - untilEach( {}, isNotNaN, log ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], 2, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], false, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], true, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], 'abc', log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], {}, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], [], log ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, 2 ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, false ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, true ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, 'abc' ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, {} ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - untilEach(); // $ExpectError - untilEach( [ 1, 2, 3 ] ); // $ExpectError - untilEach( [ 1, 2, 3 ], isNotNaN ); // $ExpectError - untilEach( [ 1, 2, 3 ], isNotNaN, log, {}, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index c41d90c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isEven = require( '@stdlib/assert-is-even' ).isPrimitive; -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var untilEach = require( './../lib' ); - -function predicate( value ) { - return ( value !== value ); -} - -function log( value, index, collection ) { - console.log( '%s: %d', index, value ); - if ( isEven( index ) ) { - collection.shift(); - } else { - collection.push( index+1 ); - } -} - -var arr; -var j; -var i; - -arr = new Array( 100 ); -j = floor( randu()*arr.length ); -for ( i = 0; i < arr.length; i++ ) { - if ( i === j ) { - arr[ i ] = NaN; - } else { - arr[ i ] = i; - } -} - -untilEach( arr, predicate, log ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index f0c7962..587a492 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..42fa034 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s,o,i,n){var l,d;if(!r(s))throw new TypeError(e("0lxBO",s));if(!t(o))throw new TypeError(e("0lx2S",o));if(!t(i))throw new TypeError(e("0lx3Z",i));for(l=s.length,d=0;d=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..4eb2813 --- /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 70a1888..0000000 --- a/test/test.js +++ /dev/null @@ -1,350 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var untilEach = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof untilEach, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {}, - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( value, noop, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a predicate function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a function to invoke', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], noop, value ); - }; - } -}); - -tape( 'if provided an empty collection, the function never invokes a provided function', function test( t ) { - var arr = []; - - function predicate() { - t.fail( 'should not be invoked' ); - } - - function foo() { - t.fail( 'should not be invoked' ); - } - - untilEach( arr, predicate, foo ); - - t.deepEqual( arr, [], 'expected result' ); - t.end(); -}); - -tape( 'the function returns the input collection', function test( t ) { - var arr; - var out; - - function predicate() { - t.pass( 'invoked predicated function' ); - return false; - } - - function foo() { - t.pass( 'invoked provided function' ); - } - - arr = [ 1, 2, 3 ]; - - out = untilEach( arr, predicate, foo ); - - t.strictEqual( out, arr, 'returns input collection' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array)', function test( t ) { - var arr; - var out; - - arr = [ 1, 2, NaN, 3 ]; - out = [ 0, 0, 0, 0 ]; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - untilEach( arr, predicate, copy ); - - t.deepEqual( out, [ 1, 2, 0, 0 ], 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array-like object)', function test( t ) { - var expected; - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = { - 'length': 4, - '0': 1, - '1': 2, - '2': NaN, - '3': 3 - }; - out = { - 'length': 4, - '0': 0, - '1': 0, - '2': 0, - '3': 0 - }; - - untilEach( arr, predicate, copy ); - - expected = { - 'length': 4, - '0': 1, - '1': 2, - '2': 0, - '3': 0 - }; - - t.deepEqual( out, expected, 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (typed array)', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = new Float64Array( [ 1.0, 2.0, NaN, 3.0 ] ); - out = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - untilEach( arr, predicate, copy ); - - t.strictEqual( out[ 0 ], 1.0, 'expected result' ); - t.strictEqual( out[ 1 ], 2.0, 'expected result' ); - t.strictEqual( out[ 2 ], 0.0, 'expected result' ); - t.strictEqual( out[ 3 ], 0.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx; - var arr; - - function predicate( value ) { - return ( value !== value ); - } - - function sum( value ) { - /* eslint-disable no-invalid-this */ - this.sum += value; - this.count += 1; - } - - ctx = { - 'sum': 0, - 'count': 0 - }; - arr = [ 1.0, 2.0, 3.0 ]; - - untilEach( arr, predicate, sum, ctx ); - - t.strictEqual( ctx.sum/ctx.count, 2.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function provides basic support for dynamic arrays', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index, collection ) { - out.push( value ); - if ( index === collection.length-1 && collection.length < 10 ) { - collection.push( index+2 ); - } - } - - arr = [ 1, 2, 3 ]; - out = []; - - untilEach( arr, predicate, copy ); - - t.deepEqual( arr, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.deepEqual( out, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.end(); -}); - -tape( 'the function does not skip empty elements', function test( t ) { - var expected; - var arr; - - function predicate( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - return false; - } - - function verify( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - } - - arr = [ 1, , , 4 ]; // eslint-disable-line no-sparse-arrays - expected = [ 1, void 0, void 0, 4 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); - -tape( 'the function invokes the predicate function and the function to apply with three arguments: value, index, collection', function test( t ) { - var indices; - var values; - var arr; - - function predicate( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - return false; - } - - function verify( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - } - - arr = [ 1, 2, 3, 4 ]; - values = [ 1, 2, 3, 4 ]; - indices = [ 0, 1, 2, 3 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); From db3d2d7753c89a7717a83493667299c2a44acc0e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 03:53:06 +0000 Subject: [PATCH 017/135] 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 846d968..0be8304 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,13 +56,13 @@ function untilEach( collection, predicate, fcn, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); + throw new TypeError( format( '0lxBO', collection ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '0lx2S', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0lx3Z', fcn ) ); } len = collection.length; i = 0; diff --git a/package.json b/package.json index 4116b70..10bba26 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-collection": "^0.0.x", "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From 1aa2edd46ea15cc00e877b4e1f7b309996f77554 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 15:10:16 +0000 Subject: [PATCH 018/135] Remove files --- index.d.ts | 142 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2836 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 587a492..0000000 --- a/index.d.ts +++ /dev/null @@ -1,142 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Collection } from '@stdlib/types/object'; - -/** -* Checks whether an element in a collection passes a test. -* -* @returns boolean indicating whether an element in a collection passes a test -*/ -type NullaryPredicate = () => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @returns boolean indicating whether an element in a collection passes a test -*/ -type UnaryPredicate = ( value: any ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @returns boolean indicating whether an element in a collection passes a test -*/ -type BinaryPredicate = ( value: any, index: number ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type TernaryPredicate = ( value: any, index: number, collection: Collection ) => boolean; // tslint-disable-line max-line-length - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Predicate = NullaryPredicate | UnaryPredicate | BinaryPredicate | TernaryPredicate; // tslint-disable-line max-line-length - -/** -* Function invoked for each collection element until test condition is true. -*/ -type Nullary = () => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -*/ -type Unary = ( value: any ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -*/ -type Binary = ( value: any, index: number ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Ternary = ( value: any, index: number, collection: Collection ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Until a test condition is true, invokes a function once for each element in a collection. -* -* ## Notes -* -* - When invoked, both the predicate function and the function to apply are provided three arguments: -* -* - `value`: collection value -* - `index`: collection index -* - `collection`: the input collection -* -* @param collection - input collection -* @param predicate - function which indicates whether to stop iterating over a collection -* @param fcn - function to invoke -* @param thisArg - execution context for the applied function -* @returns input collection -* -* @example -* function predicate( v, key, collection ) { -* return ( v !== v ); -* } -* -* function log( v, key, collection ) { -* console.log( '%s: %d', key, v ); -* } -* -* var arr = [ 1, 2, 3, 4, NaN, 5 ]; -* -* untilEach( arr, predicate, log ); -*/ -declare function untilEach( collection: Collection, predicate: Predicate, fcn: Callback, thisArg?: any ): Collection; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = untilEach; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 42fa034..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s,o,i,n){var l,d;if(!r(s))throw new TypeError(e("0lxBO",s));if(!t(o))throw new TypeError(e("0lx2S",o));if(!t(i))throw new TypeError(e("0lx3Z",i));for(l=s.length,d=0;d - - - - - - RollUp Visualizer - - - -
- - - - - From 8aa294d83aecb70186e2eeed77423a2effce2093 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 15:11:08 +0000 Subject: [PATCH 019/135] 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 | 43 +- benchmark/benchmark.js | 89 - branches.md | 53 - docs/repl.txt | 47 - docs/types/test.ts | 71 - examples/index.js | 53 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 83 - package.json | 61 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 350 --- 37 files changed, 2715 insertions(+), 3784 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 248d227..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-10-01T01:33:25.011Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 038a13c..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/utils/until-each) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f023c60..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/utils/until-each) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -282,7 +275,7 @@ untilEach( arr, predicate, log ); ## 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]. @@ -350,9 +343,9 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right +[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right/tree/esm -[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each +[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 16edfdb..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var untilEach = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var sum; - var i; - - function predicate( v ) { - return isnan( v ); - } - - function fcn( v ) { - sum += v; - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - untilEach( arr, predicate, fcn ); - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::loop', function benchmark( b ) { - var sum; - var arr; - var i; - var j; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - j = 0; - while ( j < arr.length ) { - if ( isnan( arr[ j ] ) ) { - break; - } - sum += arr[ j ]; - j += 1; - } - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2ccf847..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/utils/until-each" -click B href "https://github.com/stdlib-js/utils-until-each/tree/main" -click C href "https://github.com/stdlib-js/utils-until-each/tree/production" -click D href "https://github.com/stdlib-js/utils-until-each/tree/esm" -click E href "https://github.com/stdlib-js/utils-until-each/tree/deno" -click F href "https://github.com/stdlib-js/utils-until-each/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/until-each -[production-url]: https://github.com/stdlib-js/utils-until-each/tree/production -[deno-url]: https://github.com/stdlib-js/utils-until-each/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-until-each/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-until-each/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 11ef9f4..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,47 +0,0 @@ - -{{alias}}( collection, predicate, fcn[, thisArg] ) - Until a test condition is true, invokes a function for each element in a - collection. - - When invoked, both the predicate function and the function to apply are - provided three arguments: - - - `value`: collection value - - `index`: collection index - - `collection`: the input collection - - Parameters - ---------- - collection: Array|TypedArray|Object - Input collection over which to iterate. If provided an object, the - object must be array-like (excluding strings and functions). - - predicate: Function - The predicate function which indicates whether to stop iterating over a - collection. - - fcn: Function - The function to invoke for each element in a collection. - - thisArg: any (optional) - Execution context for the applied function. - - Returns - ------- - out: Array|TypedArray|Object - Input collection. - - Examples - -------- - > function predicate( v ) { return v !== v; }; - > function logger( v, i ) { console.log( '%s: %d', i, v ); }; - > var arr = [ 1, 2, 3, 4, NaN, 5 ]; - > {{alias}}( arr, predicate, logger ) - 0: 1 - 1: 2 - 2: 3 - 3: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 753d0bb..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,71 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 untilEach = require( './index' ); - -const log = ( v: any, index: number ): void => { - console.log( `${index}: ${v}` ); -}; - -const isNotNaN = ( v: number ): boolean => { - return ( v === v ); -}; - -// TESTS // - -// The function returns the input collection... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, log ); // $ExpectType Collection - untilEach( [ -1, 1, 2 ], isNotNaN, log, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - untilEach( 2, isNotNaN, log ); // $ExpectError - untilEach( false, isNotNaN, log ); // $ExpectError - untilEach( true, isNotNaN, log ); // $ExpectError - untilEach( {}, isNotNaN, log ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], 2, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], false, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], true, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], 'abc', log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], {}, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], [], log ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, 2 ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, false ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, true ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, 'abc' ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, {} ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - untilEach(); // $ExpectError - untilEach( [ 1, 2, 3 ] ); // $ExpectError - untilEach( [ 1, 2, 3 ], isNotNaN ); // $ExpectError - untilEach( [ 1, 2, 3 ], isNotNaN, log, {}, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index c41d90c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isEven = require( '@stdlib/assert-is-even' ).isPrimitive; -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var untilEach = require( './../lib' ); - -function predicate( value ) { - return ( value !== value ); -} - -function log( value, index, collection ) { - console.log( '%s: %d', index, value ); - if ( isEven( index ) ) { - collection.shift(); - } else { - collection.push( index+1 ); - } -} - -var arr; -var j; -var i; - -arr = new Array( 100 ); -j = floor( randu()*arr.length ); -for ( i = 0; i < arr.length; i++ ) { - if ( i === j ) { - arr[ i ] = NaN; - } else { - arr[ i ] = i; - } -} - -untilEach( arr, predicate, log ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index f0c7962..587a492 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..42fa034 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s,o,i,n){var l,d;if(!r(s))throw new TypeError(e("0lxBO",s));if(!t(o))throw new TypeError(e("0lx2S",o));if(!t(i))throw new TypeError(e("0lx3Z",i));for(l=s.length,d=0;d=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..1ee6f98 --- /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 70a1888..0000000 --- a/test/test.js +++ /dev/null @@ -1,350 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var untilEach = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof untilEach, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {}, - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( value, noop, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a predicate function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a function to invoke', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], noop, value ); - }; - } -}); - -tape( 'if provided an empty collection, the function never invokes a provided function', function test( t ) { - var arr = []; - - function predicate() { - t.fail( 'should not be invoked' ); - } - - function foo() { - t.fail( 'should not be invoked' ); - } - - untilEach( arr, predicate, foo ); - - t.deepEqual( arr, [], 'expected result' ); - t.end(); -}); - -tape( 'the function returns the input collection', function test( t ) { - var arr; - var out; - - function predicate() { - t.pass( 'invoked predicated function' ); - return false; - } - - function foo() { - t.pass( 'invoked provided function' ); - } - - arr = [ 1, 2, 3 ]; - - out = untilEach( arr, predicate, foo ); - - t.strictEqual( out, arr, 'returns input collection' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array)', function test( t ) { - var arr; - var out; - - arr = [ 1, 2, NaN, 3 ]; - out = [ 0, 0, 0, 0 ]; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - untilEach( arr, predicate, copy ); - - t.deepEqual( out, [ 1, 2, 0, 0 ], 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array-like object)', function test( t ) { - var expected; - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = { - 'length': 4, - '0': 1, - '1': 2, - '2': NaN, - '3': 3 - }; - out = { - 'length': 4, - '0': 0, - '1': 0, - '2': 0, - '3': 0 - }; - - untilEach( arr, predicate, copy ); - - expected = { - 'length': 4, - '0': 1, - '1': 2, - '2': 0, - '3': 0 - }; - - t.deepEqual( out, expected, 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (typed array)', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = new Float64Array( [ 1.0, 2.0, NaN, 3.0 ] ); - out = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - untilEach( arr, predicate, copy ); - - t.strictEqual( out[ 0 ], 1.0, 'expected result' ); - t.strictEqual( out[ 1 ], 2.0, 'expected result' ); - t.strictEqual( out[ 2 ], 0.0, 'expected result' ); - t.strictEqual( out[ 3 ], 0.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx; - var arr; - - function predicate( value ) { - return ( value !== value ); - } - - function sum( value ) { - /* eslint-disable no-invalid-this */ - this.sum += value; - this.count += 1; - } - - ctx = { - 'sum': 0, - 'count': 0 - }; - arr = [ 1.0, 2.0, 3.0 ]; - - untilEach( arr, predicate, sum, ctx ); - - t.strictEqual( ctx.sum/ctx.count, 2.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function provides basic support for dynamic arrays', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index, collection ) { - out.push( value ); - if ( index === collection.length-1 && collection.length < 10 ) { - collection.push( index+2 ); - } - } - - arr = [ 1, 2, 3 ]; - out = []; - - untilEach( arr, predicate, copy ); - - t.deepEqual( arr, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.deepEqual( out, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.end(); -}); - -tape( 'the function does not skip empty elements', function test( t ) { - var expected; - var arr; - - function predicate( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - return false; - } - - function verify( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - } - - arr = [ 1, , , 4 ]; // eslint-disable-line no-sparse-arrays - expected = [ 1, void 0, void 0, 4 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); - -tape( 'the function invokes the predicate function and the function to apply with three arguments: value, index, collection', function test( t ) { - var indices; - var values; - var arr; - - function predicate( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - return false; - } - - function verify( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - } - - arr = [ 1, 2, 3, 4 ]; - values = [ 1, 2, 3, 4 ]; - indices = [ 0, 1, 2, 3 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); From fb574db4791c89576e03583724ea092401a7d696 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 03:41:35 +0000 Subject: [PATCH 020/135] 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 846d968..0be8304 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,13 +56,13 @@ function untilEach( collection, predicate, fcn, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); + throw new TypeError( format( '0lxBO', collection ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '0lx2S', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0lx3Z', fcn ) ); } len = collection.length; i = 0; diff --git a/package.json b/package.json index 4116b70..10bba26 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-collection": "^0.0.x", "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From 169b25a7737a9fdc5e54eb4d20e47f68a79f7027 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 11:25:37 +0000 Subject: [PATCH 021/135] Remove files --- index.d.ts | 142 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2836 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 587a492..0000000 --- a/index.d.ts +++ /dev/null @@ -1,142 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Collection } from '@stdlib/types/object'; - -/** -* Checks whether an element in a collection passes a test. -* -* @returns boolean indicating whether an element in a collection passes a test -*/ -type NullaryPredicate = () => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @returns boolean indicating whether an element in a collection passes a test -*/ -type UnaryPredicate = ( value: any ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @returns boolean indicating whether an element in a collection passes a test -*/ -type BinaryPredicate = ( value: any, index: number ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type TernaryPredicate = ( value: any, index: number, collection: Collection ) => boolean; // tslint-disable-line max-line-length - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Predicate = NullaryPredicate | UnaryPredicate | BinaryPredicate | TernaryPredicate; // tslint-disable-line max-line-length - -/** -* Function invoked for each collection element until test condition is true. -*/ -type Nullary = () => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -*/ -type Unary = ( value: any ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -*/ -type Binary = ( value: any, index: number ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Ternary = ( value: any, index: number, collection: Collection ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Until a test condition is true, invokes a function once for each element in a collection. -* -* ## Notes -* -* - When invoked, both the predicate function and the function to apply are provided three arguments: -* -* - `value`: collection value -* - `index`: collection index -* - `collection`: the input collection -* -* @param collection - input collection -* @param predicate - function which indicates whether to stop iterating over a collection -* @param fcn - function to invoke -* @param thisArg - execution context for the applied function -* @returns input collection -* -* @example -* function predicate( v, key, collection ) { -* return ( v !== v ); -* } -* -* function log( v, key, collection ) { -* console.log( '%s: %d', key, v ); -* } -* -* var arr = [ 1, 2, 3, 4, NaN, 5 ]; -* -* untilEach( arr, predicate, log ); -*/ -declare function untilEach( collection: Collection, predicate: Predicate, fcn: Callback, thisArg?: any ): Collection; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = untilEach; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 42fa034..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s,o,i,n){var l,d;if(!r(s))throw new TypeError(e("0lxBO",s));if(!t(o))throw new TypeError(e("0lx2S",o));if(!t(i))throw new TypeError(e("0lx3Z",i));for(l=s.length,d=0;d - - - - - - RollUp Visualizer - - - -
- - - - - From 8f5a7f271ca491e6bc94ef22bdf8b3301edbf97c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 11:26:29 +0000 Subject: [PATCH 022/135] 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 | 43 +- benchmark/benchmark.js | 89 - branches.md | 53 - docs/repl.txt | 47 - docs/types/test.ts | 71 - examples/index.js | 53 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 83 - package.json | 61 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 350 -- 37 files changed, 4070 insertions(+), 3784 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 877bad4..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-11-01T01:21:39.815Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 038a13c..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/utils/until-each) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f023c60..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/utils/until-each) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 6610ebe..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: '35 11 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 9113bfe..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,760 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -282,7 +275,7 @@ untilEach( arr, predicate, log ); ## 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]. @@ -350,9 +343,9 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right +[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right/tree/esm -[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each +[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 16edfdb..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var untilEach = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var sum; - var i; - - function predicate( v ) { - return isnan( v ); - } - - function fcn( v ) { - sum += v; - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - untilEach( arr, predicate, fcn ); - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::loop', function benchmark( b ) { - var sum; - var arr; - var i; - var j; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - j = 0; - while ( j < arr.length ) { - if ( isnan( arr[ j ] ) ) { - break; - } - sum += arr[ j ]; - j += 1; - } - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2ccf847..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/utils/until-each" -click B href "https://github.com/stdlib-js/utils-until-each/tree/main" -click C href "https://github.com/stdlib-js/utils-until-each/tree/production" -click D href "https://github.com/stdlib-js/utils-until-each/tree/esm" -click E href "https://github.com/stdlib-js/utils-until-each/tree/deno" -click F href "https://github.com/stdlib-js/utils-until-each/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/until-each -[production-url]: https://github.com/stdlib-js/utils-until-each/tree/production -[deno-url]: https://github.com/stdlib-js/utils-until-each/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-until-each/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-until-each/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 11ef9f4..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,47 +0,0 @@ - -{{alias}}( collection, predicate, fcn[, thisArg] ) - Until a test condition is true, invokes a function for each element in a - collection. - - When invoked, both the predicate function and the function to apply are - provided three arguments: - - - `value`: collection value - - `index`: collection index - - `collection`: the input collection - - Parameters - ---------- - collection: Array|TypedArray|Object - Input collection over which to iterate. If provided an object, the - object must be array-like (excluding strings and functions). - - predicate: Function - The predicate function which indicates whether to stop iterating over a - collection. - - fcn: Function - The function to invoke for each element in a collection. - - thisArg: any (optional) - Execution context for the applied function. - - Returns - ------- - out: Array|TypedArray|Object - Input collection. - - Examples - -------- - > function predicate( v ) { return v !== v; }; - > function logger( v, i ) { console.log( '%s: %d', i, v ); }; - > var arr = [ 1, 2, 3, 4, NaN, 5 ]; - > {{alias}}( arr, predicate, logger ) - 0: 1 - 1: 2 - 2: 3 - 3: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 753d0bb..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,71 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 untilEach = require( './index' ); - -const log = ( v: any, index: number ): void => { - console.log( `${index}: ${v}` ); -}; - -const isNotNaN = ( v: number ): boolean => { - return ( v === v ); -}; - -// TESTS // - -// The function returns the input collection... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, log ); // $ExpectType Collection - untilEach( [ -1, 1, 2 ], isNotNaN, log, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - untilEach( 2, isNotNaN, log ); // $ExpectError - untilEach( false, isNotNaN, log ); // $ExpectError - untilEach( true, isNotNaN, log ); // $ExpectError - untilEach( {}, isNotNaN, log ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], 2, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], false, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], true, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], 'abc', log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], {}, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], [], log ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, 2 ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, false ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, true ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, 'abc' ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, {} ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - untilEach(); // $ExpectError - untilEach( [ 1, 2, 3 ] ); // $ExpectError - untilEach( [ 1, 2, 3 ], isNotNaN ); // $ExpectError - untilEach( [ 1, 2, 3 ], isNotNaN, log, {}, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index c41d90c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isEven = require( '@stdlib/assert-is-even' ).isPrimitive; -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var untilEach = require( './../lib' ); - -function predicate( value ) { - return ( value !== value ); -} - -function log( value, index, collection ) { - console.log( '%s: %d', index, value ); - if ( isEven( index ) ) { - collection.shift(); - } else { - collection.push( index+1 ); - } -} - -var arr; -var j; -var i; - -arr = new Array( 100 ); -j = floor( randu()*arr.length ); -for ( i = 0; i < arr.length; i++ ) { - if ( i === j ) { - arr[ i ] = NaN; - } else { - arr[ i ] = i; - } -} - -untilEach( arr, predicate, log ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index f0c7962..587a492 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..42fa034 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s,o,i,n){var l,d;if(!r(s))throw new TypeError(e("0lxBO",s));if(!t(o))throw new TypeError(e("0lx2S",o));if(!t(i))throw new TypeError(e("0lx3Z",i));for(l=s.length,d=0;d=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..98c3d87 --- /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 70a1888..0000000 --- a/test/test.js +++ /dev/null @@ -1,350 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var untilEach = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof untilEach, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {}, - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( value, noop, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a predicate function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a function to invoke', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], noop, value ); - }; - } -}); - -tape( 'if provided an empty collection, the function never invokes a provided function', function test( t ) { - var arr = []; - - function predicate() { - t.fail( 'should not be invoked' ); - } - - function foo() { - t.fail( 'should not be invoked' ); - } - - untilEach( arr, predicate, foo ); - - t.deepEqual( arr, [], 'expected result' ); - t.end(); -}); - -tape( 'the function returns the input collection', function test( t ) { - var arr; - var out; - - function predicate() { - t.pass( 'invoked predicated function' ); - return false; - } - - function foo() { - t.pass( 'invoked provided function' ); - } - - arr = [ 1, 2, 3 ]; - - out = untilEach( arr, predicate, foo ); - - t.strictEqual( out, arr, 'returns input collection' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array)', function test( t ) { - var arr; - var out; - - arr = [ 1, 2, NaN, 3 ]; - out = [ 0, 0, 0, 0 ]; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - untilEach( arr, predicate, copy ); - - t.deepEqual( out, [ 1, 2, 0, 0 ], 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array-like object)', function test( t ) { - var expected; - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = { - 'length': 4, - '0': 1, - '1': 2, - '2': NaN, - '3': 3 - }; - out = { - 'length': 4, - '0': 0, - '1': 0, - '2': 0, - '3': 0 - }; - - untilEach( arr, predicate, copy ); - - expected = { - 'length': 4, - '0': 1, - '1': 2, - '2': 0, - '3': 0 - }; - - t.deepEqual( out, expected, 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (typed array)', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = new Float64Array( [ 1.0, 2.0, NaN, 3.0 ] ); - out = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - untilEach( arr, predicate, copy ); - - t.strictEqual( out[ 0 ], 1.0, 'expected result' ); - t.strictEqual( out[ 1 ], 2.0, 'expected result' ); - t.strictEqual( out[ 2 ], 0.0, 'expected result' ); - t.strictEqual( out[ 3 ], 0.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx; - var arr; - - function predicate( value ) { - return ( value !== value ); - } - - function sum( value ) { - /* eslint-disable no-invalid-this */ - this.sum += value; - this.count += 1; - } - - ctx = { - 'sum': 0, - 'count': 0 - }; - arr = [ 1.0, 2.0, 3.0 ]; - - untilEach( arr, predicate, sum, ctx ); - - t.strictEqual( ctx.sum/ctx.count, 2.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function provides basic support for dynamic arrays', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index, collection ) { - out.push( value ); - if ( index === collection.length-1 && collection.length < 10 ) { - collection.push( index+2 ); - } - } - - arr = [ 1, 2, 3 ]; - out = []; - - untilEach( arr, predicate, copy ); - - t.deepEqual( arr, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.deepEqual( out, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.end(); -}); - -tape( 'the function does not skip empty elements', function test( t ) { - var expected; - var arr; - - function predicate( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - return false; - } - - function verify( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - } - - arr = [ 1, , , 4 ]; // eslint-disable-line no-sparse-arrays - expected = [ 1, void 0, void 0, 4 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); - -tape( 'the function invokes the predicate function and the function to apply with three arguments: value, index, collection', function test( t ) { - var indices; - var values; - var arr; - - function predicate( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - return false; - } - - function verify( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - } - - arr = [ 1, 2, 3, 4 ]; - values = [ 1, 2, 3, 4 ]; - indices = [ 0, 1, 2, 3 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); From 519cbd44351c0578d4e4f1a8b6c4e7aacc4042ed Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 00:07:27 +0000 Subject: [PATCH 023/135] 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 846d968..0be8304 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,13 +56,13 @@ function untilEach( collection, predicate, fcn, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); + throw new TypeError( format( '0lxBO', collection ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '0lx2S', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0lx3Z', fcn ) ); } len = collection.length; i = 0; diff --git a/package.json b/package.json index 4116b70..10bba26 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-collection": "^0.0.x", "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From 068e60c78d2c3450e4064267bb101e3224b0a5ae Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 07:41:00 +0000 Subject: [PATCH 024/135] Remove files --- index.d.ts | 142 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4191 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 587a492..0000000 --- a/index.d.ts +++ /dev/null @@ -1,142 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Collection } from '@stdlib/types/object'; - -/** -* Checks whether an element in a collection passes a test. -* -* @returns boolean indicating whether an element in a collection passes a test -*/ -type NullaryPredicate = () => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @returns boolean indicating whether an element in a collection passes a test -*/ -type UnaryPredicate = ( value: any ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @returns boolean indicating whether an element in a collection passes a test -*/ -type BinaryPredicate = ( value: any, index: number ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type TernaryPredicate = ( value: any, index: number, collection: Collection ) => boolean; // tslint-disable-line max-line-length - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Predicate = NullaryPredicate | UnaryPredicate | BinaryPredicate | TernaryPredicate; // tslint-disable-line max-line-length - -/** -* Function invoked for each collection element until test condition is true. -*/ -type Nullary = () => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -*/ -type Unary = ( value: any ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -*/ -type Binary = ( value: any, index: number ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Ternary = ( value: any, index: number, collection: Collection ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Until a test condition is true, invokes a function once for each element in a collection. -* -* ## Notes -* -* - When invoked, both the predicate function and the function to apply are provided three arguments: -* -* - `value`: collection value -* - `index`: collection index -* - `collection`: the input collection -* -* @param collection - input collection -* @param predicate - function which indicates whether to stop iterating over a collection -* @param fcn - function to invoke -* @param thisArg - execution context for the applied function -* @returns input collection -* -* @example -* function predicate( v, key, collection ) { -* return ( v !== v ); -* } -* -* function log( v, key, collection ) { -* console.log( '%s: %d', key, v ); -* } -* -* var arr = [ 1, 2, 3, 4, NaN, 5 ]; -* -* untilEach( arr, predicate, log ); -*/ -declare function untilEach( collection: Collection, predicate: Predicate, fcn: Callback, thisArg?: any ): Collection; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = untilEach; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 42fa034..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s,o,i,n){var l,d;if(!r(s))throw new TypeError(e("0lxBO",s));if(!t(o))throw new TypeError(e("0lx2S",o));if(!t(i))throw new TypeError(e("0lx3Z",i));for(l=s.length,d=0;d - - - - - - RollUp Visualizer - - - -
- - - - - From de20d3b5f9c944f056d73f8e3b984f0eb2c6be09 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 07:41:47 +0000 Subject: [PATCH 025/135] 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 | 43 +- benchmark/benchmark.js | 89 - branches.md | 53 - docs/repl.txt | 47 - docs/types/test.ts | 71 - examples/index.js | 53 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 83 - package.json | 61 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 350 -- 37 files changed, 4070 insertions(+), 3805 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 30e8a0a..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-11-03T21:55:22.854Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 038a13c..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/utils/until-each) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f023c60..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/utils/until-each) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 6610ebe..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: '35 11 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 37ddb4f..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,781 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -282,7 +275,7 @@ untilEach( arr, predicate, log ); ## 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]. @@ -350,9 +343,9 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right +[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right/tree/esm -[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each +[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 16edfdb..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var untilEach = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var sum; - var i; - - function predicate( v ) { - return isnan( v ); - } - - function fcn( v ) { - sum += v; - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - untilEach( arr, predicate, fcn ); - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::loop', function benchmark( b ) { - var sum; - var arr; - var i; - var j; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - j = 0; - while ( j < arr.length ) { - if ( isnan( arr[ j ] ) ) { - break; - } - sum += arr[ j ]; - j += 1; - } - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2ccf847..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/utils/until-each" -click B href "https://github.com/stdlib-js/utils-until-each/tree/main" -click C href "https://github.com/stdlib-js/utils-until-each/tree/production" -click D href "https://github.com/stdlib-js/utils-until-each/tree/esm" -click E href "https://github.com/stdlib-js/utils-until-each/tree/deno" -click F href "https://github.com/stdlib-js/utils-until-each/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/until-each -[production-url]: https://github.com/stdlib-js/utils-until-each/tree/production -[deno-url]: https://github.com/stdlib-js/utils-until-each/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-until-each/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-until-each/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 11ef9f4..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,47 +0,0 @@ - -{{alias}}( collection, predicate, fcn[, thisArg] ) - Until a test condition is true, invokes a function for each element in a - collection. - - When invoked, both the predicate function and the function to apply are - provided three arguments: - - - `value`: collection value - - `index`: collection index - - `collection`: the input collection - - Parameters - ---------- - collection: Array|TypedArray|Object - Input collection over which to iterate. If provided an object, the - object must be array-like (excluding strings and functions). - - predicate: Function - The predicate function which indicates whether to stop iterating over a - collection. - - fcn: Function - The function to invoke for each element in a collection. - - thisArg: any (optional) - Execution context for the applied function. - - Returns - ------- - out: Array|TypedArray|Object - Input collection. - - Examples - -------- - > function predicate( v ) { return v !== v; }; - > function logger( v, i ) { console.log( '%s: %d', i, v ); }; - > var arr = [ 1, 2, 3, 4, NaN, 5 ]; - > {{alias}}( arr, predicate, logger ) - 0: 1 - 1: 2 - 2: 3 - 3: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 753d0bb..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,71 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 untilEach = require( './index' ); - -const log = ( v: any, index: number ): void => { - console.log( `${index}: ${v}` ); -}; - -const isNotNaN = ( v: number ): boolean => { - return ( v === v ); -}; - -// TESTS // - -// The function returns the input collection... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, log ); // $ExpectType Collection - untilEach( [ -1, 1, 2 ], isNotNaN, log, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - untilEach( 2, isNotNaN, log ); // $ExpectError - untilEach( false, isNotNaN, log ); // $ExpectError - untilEach( true, isNotNaN, log ); // $ExpectError - untilEach( {}, isNotNaN, log ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], 2, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], false, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], true, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], 'abc', log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], {}, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], [], log ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, 2 ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, false ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, true ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, 'abc' ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, {} ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - untilEach(); // $ExpectError - untilEach( [ 1, 2, 3 ] ); // $ExpectError - untilEach( [ 1, 2, 3 ], isNotNaN ); // $ExpectError - untilEach( [ 1, 2, 3 ], isNotNaN, log, {}, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index c41d90c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isEven = require( '@stdlib/assert-is-even' ).isPrimitive; -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var untilEach = require( './../lib' ); - -function predicate( value ) { - return ( value !== value ); -} - -function log( value, index, collection ) { - console.log( '%s: %d', index, value ); - if ( isEven( index ) ) { - collection.shift(); - } else { - collection.push( index+1 ); - } -} - -var arr; -var j; -var i; - -arr = new Array( 100 ); -j = floor( randu()*arr.length ); -for ( i = 0; i < arr.length; i++ ) { - if ( i === j ) { - arr[ i ] = NaN; - } else { - arr[ i ] = i; - } -} - -untilEach( arr, predicate, log ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index f0c7962..587a492 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..42fa034 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s,o,i,n){var l,d;if(!r(s))throw new TypeError(e("0lxBO",s));if(!t(o))throw new TypeError(e("0lx2S",o));if(!t(i))throw new TypeError(e("0lx3Z",i));for(l=s.length,d=0;d=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..67ebf5b --- /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 70a1888..0000000 --- a/test/test.js +++ /dev/null @@ -1,350 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var untilEach = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof untilEach, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {}, - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( value, noop, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a predicate function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a function to invoke', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], noop, value ); - }; - } -}); - -tape( 'if provided an empty collection, the function never invokes a provided function', function test( t ) { - var arr = []; - - function predicate() { - t.fail( 'should not be invoked' ); - } - - function foo() { - t.fail( 'should not be invoked' ); - } - - untilEach( arr, predicate, foo ); - - t.deepEqual( arr, [], 'expected result' ); - t.end(); -}); - -tape( 'the function returns the input collection', function test( t ) { - var arr; - var out; - - function predicate() { - t.pass( 'invoked predicated function' ); - return false; - } - - function foo() { - t.pass( 'invoked provided function' ); - } - - arr = [ 1, 2, 3 ]; - - out = untilEach( arr, predicate, foo ); - - t.strictEqual( out, arr, 'returns input collection' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array)', function test( t ) { - var arr; - var out; - - arr = [ 1, 2, NaN, 3 ]; - out = [ 0, 0, 0, 0 ]; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - untilEach( arr, predicate, copy ); - - t.deepEqual( out, [ 1, 2, 0, 0 ], 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array-like object)', function test( t ) { - var expected; - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = { - 'length': 4, - '0': 1, - '1': 2, - '2': NaN, - '3': 3 - }; - out = { - 'length': 4, - '0': 0, - '1': 0, - '2': 0, - '3': 0 - }; - - untilEach( arr, predicate, copy ); - - expected = { - 'length': 4, - '0': 1, - '1': 2, - '2': 0, - '3': 0 - }; - - t.deepEqual( out, expected, 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (typed array)', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = new Float64Array( [ 1.0, 2.0, NaN, 3.0 ] ); - out = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - untilEach( arr, predicate, copy ); - - t.strictEqual( out[ 0 ], 1.0, 'expected result' ); - t.strictEqual( out[ 1 ], 2.0, 'expected result' ); - t.strictEqual( out[ 2 ], 0.0, 'expected result' ); - t.strictEqual( out[ 3 ], 0.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx; - var arr; - - function predicate( value ) { - return ( value !== value ); - } - - function sum( value ) { - /* eslint-disable no-invalid-this */ - this.sum += value; - this.count += 1; - } - - ctx = { - 'sum': 0, - 'count': 0 - }; - arr = [ 1.0, 2.0, 3.0 ]; - - untilEach( arr, predicate, sum, ctx ); - - t.strictEqual( ctx.sum/ctx.count, 2.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function provides basic support for dynamic arrays', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index, collection ) { - out.push( value ); - if ( index === collection.length-1 && collection.length < 10 ) { - collection.push( index+2 ); - } - } - - arr = [ 1, 2, 3 ]; - out = []; - - untilEach( arr, predicate, copy ); - - t.deepEqual( arr, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.deepEqual( out, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.end(); -}); - -tape( 'the function does not skip empty elements', function test( t ) { - var expected; - var arr; - - function predicate( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - return false; - } - - function verify( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - } - - arr = [ 1, , , 4 ]; // eslint-disable-line no-sparse-arrays - expected = [ 1, void 0, void 0, 4 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); - -tape( 'the function invokes the predicate function and the function to apply with three arguments: value, index, collection', function test( t ) { - var indices; - var values; - var arr; - - function predicate( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - return false; - } - - function verify( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - } - - arr = [ 1, 2, 3, 4 ]; - values = [ 1, 2, 3, 4 ]; - indices = [ 0, 1, 2, 3 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); From 3d4b147fc19a8280bb33da60bf358ad4aef6165d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 01:57:20 +0000 Subject: [PATCH 026/135] 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 846d968..0be8304 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,13 +56,13 @@ function untilEach( collection, predicate, fcn, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); + throw new TypeError( format( '0lxBO', collection ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '0lx2S', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0lx3Z', fcn ) ); } len = collection.length; i = 0; diff --git a/package.json b/package.json index 025505d..9e423a6 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-collection": "^0.0.x", "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From 491358d098845d77cc896f196143f249965e3f8d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 11:38:32 +0000 Subject: [PATCH 027/135] Remove files --- index.d.ts | 142 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4191 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 587a492..0000000 --- a/index.d.ts +++ /dev/null @@ -1,142 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Collection } from '@stdlib/types/object'; - -/** -* Checks whether an element in a collection passes a test. -* -* @returns boolean indicating whether an element in a collection passes a test -*/ -type NullaryPredicate = () => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @returns boolean indicating whether an element in a collection passes a test -*/ -type UnaryPredicate = ( value: any ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @returns boolean indicating whether an element in a collection passes a test -*/ -type BinaryPredicate = ( value: any, index: number ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type TernaryPredicate = ( value: any, index: number, collection: Collection ) => boolean; // tslint-disable-line max-line-length - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Predicate = NullaryPredicate | UnaryPredicate | BinaryPredicate | TernaryPredicate; // tslint-disable-line max-line-length - -/** -* Function invoked for each collection element until test condition is true. -*/ -type Nullary = () => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -*/ -type Unary = ( value: any ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -*/ -type Binary = ( value: any, index: number ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Ternary = ( value: any, index: number, collection: Collection ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Until a test condition is true, invokes a function once for each element in a collection. -* -* ## Notes -* -* - When invoked, both the predicate function and the function to apply are provided three arguments: -* -* - `value`: collection value -* - `index`: collection index -* - `collection`: the input collection -* -* @param collection - input collection -* @param predicate - function which indicates whether to stop iterating over a collection -* @param fcn - function to invoke -* @param thisArg - execution context for the applied function -* @returns input collection -* -* @example -* function predicate( v, key, collection ) { -* return ( v !== v ); -* } -* -* function log( v, key, collection ) { -* console.log( '%s: %d', key, v ); -* } -* -* var arr = [ 1, 2, 3, 4, NaN, 5 ]; -* -* untilEach( arr, predicate, log ); -*/ -declare function untilEach( collection: Collection, predicate: Predicate, fcn: Callback, thisArg?: any ): Collection; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = untilEach; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 42fa034..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s,o,i,n){var l,d;if(!r(s))throw new TypeError(e("0lxBO",s));if(!t(o))throw new TypeError(e("0lx2S",o));if(!t(i))throw new TypeError(e("0lx3Z",i));for(l=s.length,d=0;d - - - - - - RollUp Visualizer - - - -
- - - - - From 993ae30c029e4b61e2e70a37788e8e819a0d7bd4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 11:39:27 +0000 Subject: [PATCH 028/135] 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 | 43 +- benchmark/benchmark.js | 89 - branches.md | 53 - docs/repl.txt | 47 - docs/types/test.ts | 71 - examples/index.js | 53 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 83 - package.json | 61 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 350 -- 37 files changed, 4070 insertions(+), 3810 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 67c2d7f..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-12-01T01:45:13.067Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 038a13c..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/utils/until-each) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f023c60..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/utils/until-each) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 6610ebe..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: '35 11 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 37ddb4f..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,781 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -282,7 +275,7 @@ untilEach( arr, predicate, log ); ## 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]. @@ -350,9 +343,9 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right +[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right/tree/esm -[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each +[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 16edfdb..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var untilEach = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var sum; - var i; - - function predicate( v ) { - return isnan( v ); - } - - function fcn( v ) { - sum += v; - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - untilEach( arr, predicate, fcn ); - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::loop', function benchmark( b ) { - var sum; - var arr; - var i; - var j; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - j = 0; - while ( j < arr.length ) { - if ( isnan( arr[ j ] ) ) { - break; - } - sum += arr[ j ]; - j += 1; - } - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2ccf847..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/utils/until-each" -click B href "https://github.com/stdlib-js/utils-until-each/tree/main" -click C href "https://github.com/stdlib-js/utils-until-each/tree/production" -click D href "https://github.com/stdlib-js/utils-until-each/tree/esm" -click E href "https://github.com/stdlib-js/utils-until-each/tree/deno" -click F href "https://github.com/stdlib-js/utils-until-each/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/until-each -[production-url]: https://github.com/stdlib-js/utils-until-each/tree/production -[deno-url]: https://github.com/stdlib-js/utils-until-each/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-until-each/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-until-each/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 11ef9f4..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,47 +0,0 @@ - -{{alias}}( collection, predicate, fcn[, thisArg] ) - Until a test condition is true, invokes a function for each element in a - collection. - - When invoked, both the predicate function and the function to apply are - provided three arguments: - - - `value`: collection value - - `index`: collection index - - `collection`: the input collection - - Parameters - ---------- - collection: Array|TypedArray|Object - Input collection over which to iterate. If provided an object, the - object must be array-like (excluding strings and functions). - - predicate: Function - The predicate function which indicates whether to stop iterating over a - collection. - - fcn: Function - The function to invoke for each element in a collection. - - thisArg: any (optional) - Execution context for the applied function. - - Returns - ------- - out: Array|TypedArray|Object - Input collection. - - Examples - -------- - > function predicate( v ) { return v !== v; }; - > function logger( v, i ) { console.log( '%s: %d', i, v ); }; - > var arr = [ 1, 2, 3, 4, NaN, 5 ]; - > {{alias}}( arr, predicate, logger ) - 0: 1 - 1: 2 - 2: 3 - 3: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 753d0bb..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,71 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 untilEach = require( './index' ); - -const log = ( v: any, index: number ): void => { - console.log( `${index}: ${v}` ); -}; - -const isNotNaN = ( v: number ): boolean => { - return ( v === v ); -}; - -// TESTS // - -// The function returns the input collection... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, log ); // $ExpectType Collection - untilEach( [ -1, 1, 2 ], isNotNaN, log, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - untilEach( 2, isNotNaN, log ); // $ExpectError - untilEach( false, isNotNaN, log ); // $ExpectError - untilEach( true, isNotNaN, log ); // $ExpectError - untilEach( {}, isNotNaN, log ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], 2, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], false, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], true, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], 'abc', log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], {}, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], [], log ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, 2 ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, false ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, true ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, 'abc' ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, {} ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - untilEach(); // $ExpectError - untilEach( [ 1, 2, 3 ] ); // $ExpectError - untilEach( [ 1, 2, 3 ], isNotNaN ); // $ExpectError - untilEach( [ 1, 2, 3 ], isNotNaN, log, {}, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index c41d90c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isEven = require( '@stdlib/assert-is-even' ).isPrimitive; -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var untilEach = require( './../lib' ); - -function predicate( value ) { - return ( value !== value ); -} - -function log( value, index, collection ) { - console.log( '%s: %d', index, value ); - if ( isEven( index ) ) { - collection.shift(); - } else { - collection.push( index+1 ); - } -} - -var arr; -var j; -var i; - -arr = new Array( 100 ); -j = floor( randu()*arr.length ); -for ( i = 0; i < arr.length; i++ ) { - if ( i === j ) { - arr[ i ] = NaN; - } else { - arr[ i ] = i; - } -} - -untilEach( arr, predicate, log ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index f0c7962..587a492 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..42fa034 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s,o,i,n){var l,d;if(!r(s))throw new TypeError(e("0lxBO",s));if(!t(o))throw new TypeError(e("0lx2S",o));if(!t(i))throw new TypeError(e("0lx3Z",i));for(l=s.length,d=0;d=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..c598d56 --- /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 70a1888..0000000 --- a/test/test.js +++ /dev/null @@ -1,350 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var untilEach = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof untilEach, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {}, - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( value, noop, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a predicate function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a function to invoke', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], noop, value ); - }; - } -}); - -tape( 'if provided an empty collection, the function never invokes a provided function', function test( t ) { - var arr = []; - - function predicate() { - t.fail( 'should not be invoked' ); - } - - function foo() { - t.fail( 'should not be invoked' ); - } - - untilEach( arr, predicate, foo ); - - t.deepEqual( arr, [], 'expected result' ); - t.end(); -}); - -tape( 'the function returns the input collection', function test( t ) { - var arr; - var out; - - function predicate() { - t.pass( 'invoked predicated function' ); - return false; - } - - function foo() { - t.pass( 'invoked provided function' ); - } - - arr = [ 1, 2, 3 ]; - - out = untilEach( arr, predicate, foo ); - - t.strictEqual( out, arr, 'returns input collection' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array)', function test( t ) { - var arr; - var out; - - arr = [ 1, 2, NaN, 3 ]; - out = [ 0, 0, 0, 0 ]; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - untilEach( arr, predicate, copy ); - - t.deepEqual( out, [ 1, 2, 0, 0 ], 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array-like object)', function test( t ) { - var expected; - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = { - 'length': 4, - '0': 1, - '1': 2, - '2': NaN, - '3': 3 - }; - out = { - 'length': 4, - '0': 0, - '1': 0, - '2': 0, - '3': 0 - }; - - untilEach( arr, predicate, copy ); - - expected = { - 'length': 4, - '0': 1, - '1': 2, - '2': 0, - '3': 0 - }; - - t.deepEqual( out, expected, 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (typed array)', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = new Float64Array( [ 1.0, 2.0, NaN, 3.0 ] ); - out = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - untilEach( arr, predicate, copy ); - - t.strictEqual( out[ 0 ], 1.0, 'expected result' ); - t.strictEqual( out[ 1 ], 2.0, 'expected result' ); - t.strictEqual( out[ 2 ], 0.0, 'expected result' ); - t.strictEqual( out[ 3 ], 0.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx; - var arr; - - function predicate( value ) { - return ( value !== value ); - } - - function sum( value ) { - /* eslint-disable no-invalid-this */ - this.sum += value; - this.count += 1; - } - - ctx = { - 'sum': 0, - 'count': 0 - }; - arr = [ 1.0, 2.0, 3.0 ]; - - untilEach( arr, predicate, sum, ctx ); - - t.strictEqual( ctx.sum/ctx.count, 2.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function provides basic support for dynamic arrays', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index, collection ) { - out.push( value ); - if ( index === collection.length-1 && collection.length < 10 ) { - collection.push( index+2 ); - } - } - - arr = [ 1, 2, 3 ]; - out = []; - - untilEach( arr, predicate, copy ); - - t.deepEqual( arr, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.deepEqual( out, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.end(); -}); - -tape( 'the function does not skip empty elements', function test( t ) { - var expected; - var arr; - - function predicate( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - return false; - } - - function verify( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - } - - arr = [ 1, , , 4 ]; // eslint-disable-line no-sparse-arrays - expected = [ 1, void 0, void 0, 4 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); - -tape( 'the function invokes the predicate function and the function to apply with three arguments: value, index, collection', function test( t ) { - var indices; - var values; - var arr; - - function predicate( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - return false; - } - - function verify( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - } - - arr = [ 1, 2, 3, 4 ]; - values = [ 1, 2, 3, 4 ]; - indices = [ 0, 1, 2, 3 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); From 1591d845d521f143943d13f180c94c0f72b697d6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Jan 2023 02:54:36 +0000 Subject: [PATCH 029/135] 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 846d968..0be8304 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,13 +56,13 @@ function untilEach( collection, predicate, fcn, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); + throw new TypeError( format( '0lxBO', collection ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '0lx2S', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0lx3Z', fcn ) ); } len = collection.length; i = 0; diff --git a/package.json b/package.json index 19c865e..5bd09ee 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-collection": "^0.0.x", "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From b47ef5a549f2ac82ae81db2af2a7612178dee8b3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Jan 2023 10:05:28 +0000 Subject: [PATCH 030/135] Remove files --- index.d.ts | 142 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4191 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 587a492..0000000 --- a/index.d.ts +++ /dev/null @@ -1,142 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Collection } from '@stdlib/types/object'; - -/** -* Checks whether an element in a collection passes a test. -* -* @returns boolean indicating whether an element in a collection passes a test -*/ -type NullaryPredicate = () => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @returns boolean indicating whether an element in a collection passes a test -*/ -type UnaryPredicate = ( value: any ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @returns boolean indicating whether an element in a collection passes a test -*/ -type BinaryPredicate = ( value: any, index: number ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type TernaryPredicate = ( value: any, index: number, collection: Collection ) => boolean; // tslint-disable-line max-line-length - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Predicate = NullaryPredicate | UnaryPredicate | BinaryPredicate | TernaryPredicate; // tslint-disable-line max-line-length - -/** -* Function invoked for each collection element until test condition is true. -*/ -type Nullary = () => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -*/ -type Unary = ( value: any ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -*/ -type Binary = ( value: any, index: number ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Ternary = ( value: any, index: number, collection: Collection ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Until a test condition is true, invokes a function once for each element in a collection. -* -* ## Notes -* -* - When invoked, both the predicate function and the function to apply are provided three arguments: -* -* - `value`: collection value -* - `index`: collection index -* - `collection`: the input collection -* -* @param collection - input collection -* @param predicate - function which indicates whether to stop iterating over a collection -* @param fcn - function to invoke -* @param thisArg - execution context for the applied function -* @returns input collection -* -* @example -* function predicate( v, key, collection ) { -* return ( v !== v ); -* } -* -* function log( v, key, collection ) { -* console.log( '%s: %d', key, v ); -* } -* -* var arr = [ 1, 2, 3, 4, NaN, 5 ]; -* -* untilEach( arr, predicate, log ); -*/ -declare function untilEach( collection: Collection, predicate: Predicate, fcn: Callback, thisArg?: any ): Collection; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = untilEach; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 42fa034..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s,o,i,n){var l,d;if(!r(s))throw new TypeError(e("0lxBO",s));if(!t(o))throw new TypeError(e("0lx2S",o));if(!t(i))throw new TypeError(e("0lx3Z",i));for(l=s.length,d=0;d - - - - - - RollUp Visualizer - - - -
- - - - - From e7f6b0c8e82cfc471caacd4eee31348c376ace08 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Jan 2023 10:06:14 +0000 Subject: [PATCH 031/135] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 791 ---- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 184 - .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 43 +- benchmark/benchmark.js | 89 - branches.md | 53 - docs/repl.txt | 47 - docs/types/test.ts | 71 - examples/index.js | 53 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 83 - package.json | 61 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 350 -- 37 files changed, 4070 insertions(+), 3821 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 41dd4fb..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-01-01T01:11:40.771Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 038a13c..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/utils/until-each) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f023c60..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/utils/until-each) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 6610ebe..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: '35 11 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4eea88..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,791 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -282,7 +275,7 @@ untilEach( arr, predicate, log ); ## 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]. @@ -350,9 +343,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right +[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right/tree/esm -[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each +[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 16edfdb..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var untilEach = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var sum; - var i; - - function predicate( v ) { - return isnan( v ); - } - - function fcn( v ) { - sum += v; - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - untilEach( arr, predicate, fcn ); - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::loop', function benchmark( b ) { - var sum; - var arr; - var i; - var j; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - j = 0; - while ( j < arr.length ) { - if ( isnan( arr[ j ] ) ) { - break; - } - sum += arr[ j ]; - j += 1; - } - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2ccf847..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/utils/until-each" -click B href "https://github.com/stdlib-js/utils-until-each/tree/main" -click C href "https://github.com/stdlib-js/utils-until-each/tree/production" -click D href "https://github.com/stdlib-js/utils-until-each/tree/esm" -click E href "https://github.com/stdlib-js/utils-until-each/tree/deno" -click F href "https://github.com/stdlib-js/utils-until-each/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/until-each -[production-url]: https://github.com/stdlib-js/utils-until-each/tree/production -[deno-url]: https://github.com/stdlib-js/utils-until-each/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-until-each/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-until-each/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 11ef9f4..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,47 +0,0 @@ - -{{alias}}( collection, predicate, fcn[, thisArg] ) - Until a test condition is true, invokes a function for each element in a - collection. - - When invoked, both the predicate function and the function to apply are - provided three arguments: - - - `value`: collection value - - `index`: collection index - - `collection`: the input collection - - Parameters - ---------- - collection: Array|TypedArray|Object - Input collection over which to iterate. If provided an object, the - object must be array-like (excluding strings and functions). - - predicate: Function - The predicate function which indicates whether to stop iterating over a - collection. - - fcn: Function - The function to invoke for each element in a collection. - - thisArg: any (optional) - Execution context for the applied function. - - Returns - ------- - out: Array|TypedArray|Object - Input collection. - - Examples - -------- - > function predicate( v ) { return v !== v; }; - > function logger( v, i ) { console.log( '%s: %d', i, v ); }; - > var arr = [ 1, 2, 3, 4, NaN, 5 ]; - > {{alias}}( arr, predicate, logger ) - 0: 1 - 1: 2 - 2: 3 - 3: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 753d0bb..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,71 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 untilEach = require( './index' ); - -const log = ( v: any, index: number ): void => { - console.log( `${index}: ${v}` ); -}; - -const isNotNaN = ( v: number ): boolean => { - return ( v === v ); -}; - -// TESTS // - -// The function returns the input collection... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, log ); // $ExpectType Collection - untilEach( [ -1, 1, 2 ], isNotNaN, log, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - untilEach( 2, isNotNaN, log ); // $ExpectError - untilEach( false, isNotNaN, log ); // $ExpectError - untilEach( true, isNotNaN, log ); // $ExpectError - untilEach( {}, isNotNaN, log ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], 2, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], false, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], true, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], 'abc', log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], {}, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], [], log ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, 2 ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, false ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, true ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, 'abc' ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, {} ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - untilEach(); // $ExpectError - untilEach( [ 1, 2, 3 ] ); // $ExpectError - untilEach( [ 1, 2, 3 ], isNotNaN ); // $ExpectError - untilEach( [ 1, 2, 3 ], isNotNaN, log, {}, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index c41d90c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isEven = require( '@stdlib/assert-is-even' ).isPrimitive; -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var untilEach = require( './../lib' ); - -function predicate( value ) { - return ( value !== value ); -} - -function log( value, index, collection ) { - console.log( '%s: %d', index, value ); - if ( isEven( index ) ) { - collection.shift(); - } else { - collection.push( index+1 ); - } -} - -var arr; -var j; -var i; - -arr = new Array( 100 ); -j = floor( randu()*arr.length ); -for ( i = 0; i < arr.length; i++ ) { - if ( i === j ) { - arr[ i ] = NaN; - } else { - arr[ i ] = i; - } -} - -untilEach( arr, predicate, log ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index f0c7962..587a492 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..1f35a3f --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s,o,i,n){var l,d;if(!r(s))throw new TypeError(e("0lxBO",s));if(!t(o))throw new TypeError(e("0lx2S",o));if(!t(i))throw new TypeError(e("0lx3Z",i));for(l=s.length,d=0;d=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..7f6d2de --- /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 70a1888..0000000 --- a/test/test.js +++ /dev/null @@ -1,350 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var untilEach = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof untilEach, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {}, - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( value, noop, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a predicate function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a function to invoke', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], noop, value ); - }; - } -}); - -tape( 'if provided an empty collection, the function never invokes a provided function', function test( t ) { - var arr = []; - - function predicate() { - t.fail( 'should not be invoked' ); - } - - function foo() { - t.fail( 'should not be invoked' ); - } - - untilEach( arr, predicate, foo ); - - t.deepEqual( arr, [], 'expected result' ); - t.end(); -}); - -tape( 'the function returns the input collection', function test( t ) { - var arr; - var out; - - function predicate() { - t.pass( 'invoked predicated function' ); - return false; - } - - function foo() { - t.pass( 'invoked provided function' ); - } - - arr = [ 1, 2, 3 ]; - - out = untilEach( arr, predicate, foo ); - - t.strictEqual( out, arr, 'returns input collection' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array)', function test( t ) { - var arr; - var out; - - arr = [ 1, 2, NaN, 3 ]; - out = [ 0, 0, 0, 0 ]; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - untilEach( arr, predicate, copy ); - - t.deepEqual( out, [ 1, 2, 0, 0 ], 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array-like object)', function test( t ) { - var expected; - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = { - 'length': 4, - '0': 1, - '1': 2, - '2': NaN, - '3': 3 - }; - out = { - 'length': 4, - '0': 0, - '1': 0, - '2': 0, - '3': 0 - }; - - untilEach( arr, predicate, copy ); - - expected = { - 'length': 4, - '0': 1, - '1': 2, - '2': 0, - '3': 0 - }; - - t.deepEqual( out, expected, 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (typed array)', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = new Float64Array( [ 1.0, 2.0, NaN, 3.0 ] ); - out = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - untilEach( arr, predicate, copy ); - - t.strictEqual( out[ 0 ], 1.0, 'expected result' ); - t.strictEqual( out[ 1 ], 2.0, 'expected result' ); - t.strictEqual( out[ 2 ], 0.0, 'expected result' ); - t.strictEqual( out[ 3 ], 0.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx; - var arr; - - function predicate( value ) { - return ( value !== value ); - } - - function sum( value ) { - /* eslint-disable no-invalid-this */ - this.sum += value; - this.count += 1; - } - - ctx = { - 'sum': 0, - 'count': 0 - }; - arr = [ 1.0, 2.0, 3.0 ]; - - untilEach( arr, predicate, sum, ctx ); - - t.strictEqual( ctx.sum/ctx.count, 2.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function provides basic support for dynamic arrays', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index, collection ) { - out.push( value ); - if ( index === collection.length-1 && collection.length < 10 ) { - collection.push( index+2 ); - } - } - - arr = [ 1, 2, 3 ]; - out = []; - - untilEach( arr, predicate, copy ); - - t.deepEqual( arr, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.deepEqual( out, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.end(); -}); - -tape( 'the function does not skip empty elements', function test( t ) { - var expected; - var arr; - - function predicate( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - return false; - } - - function verify( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - } - - arr = [ 1, , , 4 ]; // eslint-disable-line no-sparse-arrays - expected = [ 1, void 0, void 0, 4 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); - -tape( 'the function invokes the predicate function and the function to apply with three arguments: value, index, collection', function test( t ) { - var indices; - var values; - var arr; - - function predicate( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - return false; - } - - function verify( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - } - - arr = [ 1, 2, 3, 4 ]; - values = [ 1, 2, 3, 4 ]; - indices = [ 0, 1, 2, 3 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); From 988947a27c309e3134462ca6b868a49aae106659 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 03:48:39 +0000 Subject: [PATCH 032/135] 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 846d968..0be8304 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,13 +56,13 @@ function untilEach( collection, predicate, fcn, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); + throw new TypeError( format( '0lxBO', collection ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '0lx2S', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0lx3Z', fcn ) ); } len = collection.length; i = 0; diff --git a/package.json b/package.json index 19c865e..5bd09ee 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-collection": "^0.0.x", "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/string-format": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x", "@stdlib/types": "^0.0.x" }, "devDependencies": { From fe6b884057110eb827290c9e24c6fcd1f0457bd4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 12:04:43 +0000 Subject: [PATCH 033/135] Remove files --- index.d.ts | 142 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4191 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 587a492..0000000 --- a/index.d.ts +++ /dev/null @@ -1,142 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Collection } from '@stdlib/types/object'; - -/** -* Checks whether an element in a collection passes a test. -* -* @returns boolean indicating whether an element in a collection passes a test -*/ -type NullaryPredicate = () => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @returns boolean indicating whether an element in a collection passes a test -*/ -type UnaryPredicate = ( value: any ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @returns boolean indicating whether an element in a collection passes a test -*/ -type BinaryPredicate = ( value: any, index: number ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type TernaryPredicate = ( value: any, index: number, collection: Collection ) => boolean; // tslint-disable-line max-line-length - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Predicate = NullaryPredicate | UnaryPredicate | BinaryPredicate | TernaryPredicate; // tslint-disable-line max-line-length - -/** -* Function invoked for each collection element until test condition is true. -*/ -type Nullary = () => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -*/ -type Unary = ( value: any ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -*/ -type Binary = ( value: any, index: number ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Ternary = ( value: any, index: number, collection: Collection ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Until a test condition is true, invokes a function once for each element in a collection. -* -* ## Notes -* -* - When invoked, both the predicate function and the function to apply are provided three arguments: -* -* - `value`: collection value -* - `index`: collection index -* - `collection`: the input collection -* -* @param collection - input collection -* @param predicate - function which indicates whether to stop iterating over a collection -* @param fcn - function to invoke -* @param thisArg - execution context for the applied function -* @returns input collection -* -* @example -* function predicate( v, key, collection ) { -* return ( v !== v ); -* } -* -* function log( v, key, collection ) { -* console.log( '%s: %d', key, v ); -* } -* -* var arr = [ 1, 2, 3, 4, NaN, 5 ]; -* -* untilEach( arr, predicate, log ); -*/ -declare function untilEach( collection: Collection, predicate: Predicate, fcn: Callback, thisArg?: any ): Collection; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = untilEach; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 1f35a3f..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s,o,i,n){var l,d;if(!r(s))throw new TypeError(e("0lxBO",s));if(!t(o))throw new TypeError(e("0lx2S",o));if(!t(i))throw new TypeError(e("0lx3Z",i));for(l=s.length,d=0;d - - - - - - RollUp Visualizer - - - -
- - - - - From 42ae0c5e1ad56a3b45eee75830e52db341969ec3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 12:05:24 +0000 Subject: [PATCH 034/135] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 791 --- .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 184 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 43 +- benchmark/benchmark.js | 89 - branches.md | 53 - docs/repl.txt | 47 - docs/types/test.ts | 71 - examples/index.js | 53 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 83 - package.json | 61 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 350 -- 37 files changed, 6203 insertions(+), 3821 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index bcb95db..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-02-01T01:34:07.114Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 038a13c..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/utils/until-each) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f023c60..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/utils/until-each) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 6610ebe..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: '35 11 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4eea88..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,791 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -282,7 +275,7 @@ untilEach( arr, predicate, log ); ## 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]. @@ -350,9 +343,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right +[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right/tree/esm -[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each +[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 16edfdb..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var untilEach = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var sum; - var i; - - function predicate( v ) { - return isnan( v ); - } - - function fcn( v ) { - sum += v; - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - untilEach( arr, predicate, fcn ); - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::loop', function benchmark( b ) { - var sum; - var arr; - var i; - var j; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - j = 0; - while ( j < arr.length ) { - if ( isnan( arr[ j ] ) ) { - break; - } - sum += arr[ j ]; - j += 1; - } - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2ccf847..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/utils/until-each" -click B href "https://github.com/stdlib-js/utils-until-each/tree/main" -click C href "https://github.com/stdlib-js/utils-until-each/tree/production" -click D href "https://github.com/stdlib-js/utils-until-each/tree/esm" -click E href "https://github.com/stdlib-js/utils-until-each/tree/deno" -click F href "https://github.com/stdlib-js/utils-until-each/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/until-each -[production-url]: https://github.com/stdlib-js/utils-until-each/tree/production -[deno-url]: https://github.com/stdlib-js/utils-until-each/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-until-each/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-until-each/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 11ef9f4..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,47 +0,0 @@ - -{{alias}}( collection, predicate, fcn[, thisArg] ) - Until a test condition is true, invokes a function for each element in a - collection. - - When invoked, both the predicate function and the function to apply are - provided three arguments: - - - `value`: collection value - - `index`: collection index - - `collection`: the input collection - - Parameters - ---------- - collection: Array|TypedArray|Object - Input collection over which to iterate. If provided an object, the - object must be array-like (excluding strings and functions). - - predicate: Function - The predicate function which indicates whether to stop iterating over a - collection. - - fcn: Function - The function to invoke for each element in a collection. - - thisArg: any (optional) - Execution context for the applied function. - - Returns - ------- - out: Array|TypedArray|Object - Input collection. - - Examples - -------- - > function predicate( v ) { return v !== v; }; - > function logger( v, i ) { console.log( '%s: %d', i, v ); }; - > var arr = [ 1, 2, 3, 4, NaN, 5 ]; - > {{alias}}( arr, predicate, logger ) - 0: 1 - 1: 2 - 2: 3 - 3: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 753d0bb..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,71 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 untilEach = require( './index' ); - -const log = ( v: any, index: number ): void => { - console.log( `${index}: ${v}` ); -}; - -const isNotNaN = ( v: number ): boolean => { - return ( v === v ); -}; - -// TESTS // - -// The function returns the input collection... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, log ); // $ExpectType Collection - untilEach( [ -1, 1, 2 ], isNotNaN, log, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - untilEach( 2, isNotNaN, log ); // $ExpectError - untilEach( false, isNotNaN, log ); // $ExpectError - untilEach( true, isNotNaN, log ); // $ExpectError - untilEach( {}, isNotNaN, log ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], 2, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], false, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], true, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], 'abc', log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], {}, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], [], log ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, 2 ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, false ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, true ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, 'abc' ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, {} ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - untilEach(); // $ExpectError - untilEach( [ 1, 2, 3 ] ); // $ExpectError - untilEach( [ 1, 2, 3 ], isNotNaN ); // $ExpectError - untilEach( [ 1, 2, 3 ], isNotNaN, log, {}, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index c41d90c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isEven = require( '@stdlib/assert-is-even' ).isPrimitive; -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var untilEach = require( './../lib' ); - -function predicate( value ) { - return ( value !== value ); -} - -function log( value, index, collection ) { - console.log( '%s: %d', index, value ); - if ( isEven( index ) ) { - collection.shift(); - } else { - collection.push( index+1 ); - } -} - -var arr; -var j; -var i; - -arr = new Array( 100 ); -j = floor( randu()*arr.length ); -for ( i = 0; i < arr.length; i++ ) { - if ( i === j ) { - arr[ i ] = NaN; - } else { - arr[ i ] = i; - } -} - -untilEach( arr, predicate, log ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index f0c7962..587a492 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..1f35a3f --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s,o,i,n){var l,d;if(!r(s))throw new TypeError(e("0lxBO",s));if(!t(o))throw new TypeError(e("0lx2S",o));if(!t(i))throw new TypeError(e("0lx3Z",i));for(l=s.length,d=0;d=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..a11ad20 --- /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 70a1888..0000000 --- a/test/test.js +++ /dev/null @@ -1,350 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var untilEach = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof untilEach, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {}, - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( value, noop, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a predicate function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a function to invoke', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], noop, value ); - }; - } -}); - -tape( 'if provided an empty collection, the function never invokes a provided function', function test( t ) { - var arr = []; - - function predicate() { - t.fail( 'should not be invoked' ); - } - - function foo() { - t.fail( 'should not be invoked' ); - } - - untilEach( arr, predicate, foo ); - - t.deepEqual( arr, [], 'expected result' ); - t.end(); -}); - -tape( 'the function returns the input collection', function test( t ) { - var arr; - var out; - - function predicate() { - t.pass( 'invoked predicated function' ); - return false; - } - - function foo() { - t.pass( 'invoked provided function' ); - } - - arr = [ 1, 2, 3 ]; - - out = untilEach( arr, predicate, foo ); - - t.strictEqual( out, arr, 'returns input collection' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array)', function test( t ) { - var arr; - var out; - - arr = [ 1, 2, NaN, 3 ]; - out = [ 0, 0, 0, 0 ]; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - untilEach( arr, predicate, copy ); - - t.deepEqual( out, [ 1, 2, 0, 0 ], 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array-like object)', function test( t ) { - var expected; - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = { - 'length': 4, - '0': 1, - '1': 2, - '2': NaN, - '3': 3 - }; - out = { - 'length': 4, - '0': 0, - '1': 0, - '2': 0, - '3': 0 - }; - - untilEach( arr, predicate, copy ); - - expected = { - 'length': 4, - '0': 1, - '1': 2, - '2': 0, - '3': 0 - }; - - t.deepEqual( out, expected, 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (typed array)', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = new Float64Array( [ 1.0, 2.0, NaN, 3.0 ] ); - out = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - untilEach( arr, predicate, copy ); - - t.strictEqual( out[ 0 ], 1.0, 'expected result' ); - t.strictEqual( out[ 1 ], 2.0, 'expected result' ); - t.strictEqual( out[ 2 ], 0.0, 'expected result' ); - t.strictEqual( out[ 3 ], 0.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx; - var arr; - - function predicate( value ) { - return ( value !== value ); - } - - function sum( value ) { - /* eslint-disable no-invalid-this */ - this.sum += value; - this.count += 1; - } - - ctx = { - 'sum': 0, - 'count': 0 - }; - arr = [ 1.0, 2.0, 3.0 ]; - - untilEach( arr, predicate, sum, ctx ); - - t.strictEqual( ctx.sum/ctx.count, 2.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function provides basic support for dynamic arrays', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index, collection ) { - out.push( value ); - if ( index === collection.length-1 && collection.length < 10 ) { - collection.push( index+2 ); - } - } - - arr = [ 1, 2, 3 ]; - out = []; - - untilEach( arr, predicate, copy ); - - t.deepEqual( arr, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.deepEqual( out, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.end(); -}); - -tape( 'the function does not skip empty elements', function test( t ) { - var expected; - var arr; - - function predicate( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - return false; - } - - function verify( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - } - - arr = [ 1, , , 4 ]; // eslint-disable-line no-sparse-arrays - expected = [ 1, void 0, void 0, 4 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); - -tape( 'the function invokes the predicate function and the function to apply with three arguments: value, index, collection', function test( t ) { - var indices; - var values; - var arr; - - function predicate( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - return false; - } - - function verify( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - } - - arr = [ 1, 2, 3, 4 ]; - values = [ 1, 2, 3, 4 ]; - indices = [ 0, 1, 2, 3 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); From 098c5a81e5faa5b3dd057df112f1bb5a60f98e1d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Mar 2023 05:49:13 +0000 Subject: [PATCH 035/135] 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 846d968..0be8304 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,13 +56,13 @@ function untilEach( collection, predicate, fcn, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); + throw new TypeError( format( '0lxBO', collection ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '0lx2S', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0lx3Z', fcn ) ); } len = collection.length; i = 0; diff --git a/package.json b/package.json index 66f6f95..129e621 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-collection": "^0.0.8", "@stdlib/assert-is-function": "^0.0.8", - "@stdlib/string-format": "^0.0.3", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2", "@stdlib/types": "^0.0.14" }, "devDependencies": { From f887c31f20f3f1ee64b8d8400b47d41a65804b1d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Mar 2023 14:18:30 +0000 Subject: [PATCH 036/135] Remove files --- index.d.ts | 142 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6324 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 587a492..0000000 --- a/index.d.ts +++ /dev/null @@ -1,142 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Collection } from '@stdlib/types/object'; - -/** -* Checks whether an element in a collection passes a test. -* -* @returns boolean indicating whether an element in a collection passes a test -*/ -type NullaryPredicate = () => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @returns boolean indicating whether an element in a collection passes a test -*/ -type UnaryPredicate = ( value: any ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @returns boolean indicating whether an element in a collection passes a test -*/ -type BinaryPredicate = ( value: any, index: number ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type TernaryPredicate = ( value: any, index: number, collection: Collection ) => boolean; // tslint-disable-line max-line-length - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Predicate = NullaryPredicate | UnaryPredicate | BinaryPredicate | TernaryPredicate; // tslint-disable-line max-line-length - -/** -* Function invoked for each collection element until test condition is true. -*/ -type Nullary = () => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -*/ -type Unary = ( value: any ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -*/ -type Binary = ( value: any, index: number ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Ternary = ( value: any, index: number, collection: Collection ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Until a test condition is true, invokes a function once for each element in a collection. -* -* ## Notes -* -* - When invoked, both the predicate function and the function to apply are provided three arguments: -* -* - `value`: collection value -* - `index`: collection index -* - `collection`: the input collection -* -* @param collection - input collection -* @param predicate - function which indicates whether to stop iterating over a collection -* @param fcn - function to invoke -* @param thisArg - execution context for the applied function -* @returns input collection -* -* @example -* function predicate( v, key, collection ) { -* return ( v !== v ); -* } -* -* function log( v, key, collection ) { -* console.log( '%s: %d', key, v ); -* } -* -* var arr = [ 1, 2, 3, 4, NaN, 5 ]; -* -* untilEach( arr, predicate, log ); -*/ -declare function untilEach( collection: Collection, predicate: Predicate, fcn: Callback, thisArg?: any ): Collection; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = untilEach; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 1f35a3f..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s,o,i,n){var l,d;if(!r(s))throw new TypeError(e("0lxBO",s));if(!t(o))throw new TypeError(e("0lx2S",o));if(!t(i))throw new TypeError(e("0lx3Z",i));for(l=s.length,d=0;d - - - - - - Rollup Visualizer - - - -
- - - - - From c71e2aaf098ed2bb7dc1a9de0c31eb46dd4e1999 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Mar 2023 14:19:12 +0000 Subject: [PATCH 037/135] 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 | 798 --- .github/workflows/publish.yml | 236 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 43 +- benchmark/benchmark.js | 89 - branches.md | 53 - docs/repl.txt | 47 - docs/types/test.ts | 71 - examples/index.js | 53 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 83 - package.json | 61 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 350 -- 37 files changed, 6203 insertions(+), 3956 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 143035a..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-03-01T03:46:26.957Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 038a13c..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/utils/until-each) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f023c60..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/utils/until-each) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 6610ebe..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: '35 11 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 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 + + ```
@@ -282,7 +275,7 @@ untilEach( arr, predicate, log ); ## 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]. @@ -350,9 +343,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right +[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right/tree/esm -[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each +[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 16edfdb..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var untilEach = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var sum; - var i; - - function predicate( v ) { - return isnan( v ); - } - - function fcn( v ) { - sum += v; - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - untilEach( arr, predicate, fcn ); - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::loop', function benchmark( b ) { - var sum; - var arr; - var i; - var j; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - j = 0; - while ( j < arr.length ) { - if ( isnan( arr[ j ] ) ) { - break; - } - sum += arr[ j ]; - j += 1; - } - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 3a445ad..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/utils/until-each" -%% click B href "https://github.com/stdlib-js/utils-until-each/tree/main" -%% click C href "https://github.com/stdlib-js/utils-until-each/tree/production" -%% click D href "https://github.com/stdlib-js/utils-until-each/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-until-each/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-until-each/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/until-each -[production-url]: https://github.com/stdlib-js/utils-until-each/tree/production -[deno-url]: https://github.com/stdlib-js/utils-until-each/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-until-each/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-until-each/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 11ef9f4..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,47 +0,0 @@ - -{{alias}}( collection, predicate, fcn[, thisArg] ) - Until a test condition is true, invokes a function for each element in a - collection. - - When invoked, both the predicate function and the function to apply are - provided three arguments: - - - `value`: collection value - - `index`: collection index - - `collection`: the input collection - - Parameters - ---------- - collection: Array|TypedArray|Object - Input collection over which to iterate. If provided an object, the - object must be array-like (excluding strings and functions). - - predicate: Function - The predicate function which indicates whether to stop iterating over a - collection. - - fcn: Function - The function to invoke for each element in a collection. - - thisArg: any (optional) - Execution context for the applied function. - - Returns - ------- - out: Array|TypedArray|Object - Input collection. - - Examples - -------- - > function predicate( v ) { return v !== v; }; - > function logger( v, i ) { console.log( '%s: %d', i, v ); }; - > var arr = [ 1, 2, 3, 4, NaN, 5 ]; - > {{alias}}( arr, predicate, logger ) - 0: 1 - 1: 2 - 2: 3 - 3: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 753d0bb..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,71 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 untilEach = require( './index' ); - -const log = ( v: any, index: number ): void => { - console.log( `${index}: ${v}` ); -}; - -const isNotNaN = ( v: number ): boolean => { - return ( v === v ); -}; - -// TESTS // - -// The function returns the input collection... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, log ); // $ExpectType Collection - untilEach( [ -1, 1, 2 ], isNotNaN, log, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - untilEach( 2, isNotNaN, log ); // $ExpectError - untilEach( false, isNotNaN, log ); // $ExpectError - untilEach( true, isNotNaN, log ); // $ExpectError - untilEach( {}, isNotNaN, log ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], 2, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], false, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], true, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], 'abc', log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], {}, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], [], log ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, 2 ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, false ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, true ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, 'abc' ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, {} ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - untilEach(); // $ExpectError - untilEach( [ 1, 2, 3 ] ); // $ExpectError - untilEach( [ 1, 2, 3 ], isNotNaN ); // $ExpectError - untilEach( [ 1, 2, 3 ], isNotNaN, log, {}, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index c41d90c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isEven = require( '@stdlib/assert-is-even' ).isPrimitive; -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var untilEach = require( './../lib' ); - -function predicate( value ) { - return ( value !== value ); -} - -function log( value, index, collection ) { - console.log( '%s: %d', index, value ); - if ( isEven( index ) ) { - collection.shift(); - } else { - collection.push( index+1 ); - } -} - -var arr; -var j; -var i; - -arr = new Array( 100 ); -j = floor( randu()*arr.length ); -for ( i = 0; i < arr.length; i++ ) { - if ( i === j ) { - arr[ i ] = NaN; - } else { - arr[ i ] = i; - } -} - -untilEach( arr, predicate, log ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index f0c7962..587a492 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..1f35a3f --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s,o,i,n){var l,d;if(!r(s))throw new TypeError(e("0lxBO",s));if(!t(o))throw new TypeError(e("0lx2S",o));if(!t(i))throw new TypeError(e("0lx3Z",i));for(l=s.length,d=0;d=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..c47967d --- /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 70a1888..0000000 --- a/test/test.js +++ /dev/null @@ -1,350 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var untilEach = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof untilEach, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {}, - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( value, noop, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a predicate function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a function to invoke', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], noop, value ); - }; - } -}); - -tape( 'if provided an empty collection, the function never invokes a provided function', function test( t ) { - var arr = []; - - function predicate() { - t.fail( 'should not be invoked' ); - } - - function foo() { - t.fail( 'should not be invoked' ); - } - - untilEach( arr, predicate, foo ); - - t.deepEqual( arr, [], 'expected result' ); - t.end(); -}); - -tape( 'the function returns the input collection', function test( t ) { - var arr; - var out; - - function predicate() { - t.pass( 'invoked predicated function' ); - return false; - } - - function foo() { - t.pass( 'invoked provided function' ); - } - - arr = [ 1, 2, 3 ]; - - out = untilEach( arr, predicate, foo ); - - t.strictEqual( out, arr, 'returns input collection' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array)', function test( t ) { - var arr; - var out; - - arr = [ 1, 2, NaN, 3 ]; - out = [ 0, 0, 0, 0 ]; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - untilEach( arr, predicate, copy ); - - t.deepEqual( out, [ 1, 2, 0, 0 ], 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array-like object)', function test( t ) { - var expected; - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = { - 'length': 4, - '0': 1, - '1': 2, - '2': NaN, - '3': 3 - }; - out = { - 'length': 4, - '0': 0, - '1': 0, - '2': 0, - '3': 0 - }; - - untilEach( arr, predicate, copy ); - - expected = { - 'length': 4, - '0': 1, - '1': 2, - '2': 0, - '3': 0 - }; - - t.deepEqual( out, expected, 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (typed array)', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = new Float64Array( [ 1.0, 2.0, NaN, 3.0 ] ); - out = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - untilEach( arr, predicate, copy ); - - t.strictEqual( out[ 0 ], 1.0, 'expected result' ); - t.strictEqual( out[ 1 ], 2.0, 'expected result' ); - t.strictEqual( out[ 2 ], 0.0, 'expected result' ); - t.strictEqual( out[ 3 ], 0.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx; - var arr; - - function predicate( value ) { - return ( value !== value ); - } - - function sum( value ) { - /* eslint-disable no-invalid-this */ - this.sum += value; - this.count += 1; - } - - ctx = { - 'sum': 0, - 'count': 0 - }; - arr = [ 1.0, 2.0, 3.0 ]; - - untilEach( arr, predicate, sum, ctx ); - - t.strictEqual( ctx.sum/ctx.count, 2.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function provides basic support for dynamic arrays', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index, collection ) { - out.push( value ); - if ( index === collection.length-1 && collection.length < 10 ) { - collection.push( index+2 ); - } - } - - arr = [ 1, 2, 3 ]; - out = []; - - untilEach( arr, predicate, copy ); - - t.deepEqual( arr, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.deepEqual( out, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.end(); -}); - -tape( 'the function does not skip empty elements', function test( t ) { - var expected; - var arr; - - function predicate( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - return false; - } - - function verify( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - } - - arr = [ 1, , , 4 ]; // eslint-disable-line no-sparse-arrays - expected = [ 1, void 0, void 0, 4 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); - -tape( 'the function invokes the predicate function and the function to apply with three arguments: value, index, collection', function test( t ) { - var indices; - var values; - var arr; - - function predicate( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - return false; - } - - function verify( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - } - - arr = [ 1, 2, 3, 4 ]; - values = [ 1, 2, 3, 4 ]; - indices = [ 0, 1, 2, 3 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); From 0dc506d05f3afddc64f1d6565c92f492440500e2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Apr 2023 06:24:37 +0000 Subject: [PATCH 038/135] 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 846d968..0be8304 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,13 +56,13 @@ function untilEach( collection, predicate, fcn, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); + throw new TypeError( format( '0lxBO', collection ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '0lx2S', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0lx3Z', fcn ) ); } len = collection.length; i = 0; diff --git a/package.json b/package.json index 66f6f95..129e621 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-collection": "^0.0.8", "@stdlib/assert-is-function": "^0.0.8", - "@stdlib/string-format": "^0.0.3", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2", "@stdlib/types": "^0.0.14" }, "devDependencies": { From 722a135b98a3ec3764dc945b89c81a0889a7e090 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Apr 2023 13:17:22 +0000 Subject: [PATCH 039/135] Remove files --- index.d.ts | 142 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6324 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 587a492..0000000 --- a/index.d.ts +++ /dev/null @@ -1,142 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Collection } from '@stdlib/types/object'; - -/** -* Checks whether an element in a collection passes a test. -* -* @returns boolean indicating whether an element in a collection passes a test -*/ -type NullaryPredicate = () => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @returns boolean indicating whether an element in a collection passes a test -*/ -type UnaryPredicate = ( value: any ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @returns boolean indicating whether an element in a collection passes a test -*/ -type BinaryPredicate = ( value: any, index: number ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type TernaryPredicate = ( value: any, index: number, collection: Collection ) => boolean; // tslint-disable-line max-line-length - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Predicate = NullaryPredicate | UnaryPredicate | BinaryPredicate | TernaryPredicate; // tslint-disable-line max-line-length - -/** -* Function invoked for each collection element until test condition is true. -*/ -type Nullary = () => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -*/ -type Unary = ( value: any ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -*/ -type Binary = ( value: any, index: number ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Ternary = ( value: any, index: number, collection: Collection ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Until a test condition is true, invokes a function once for each element in a collection. -* -* ## Notes -* -* - When invoked, both the predicate function and the function to apply are provided three arguments: -* -* - `value`: collection value -* - `index`: collection index -* - `collection`: the input collection -* -* @param collection - input collection -* @param predicate - function which indicates whether to stop iterating over a collection -* @param fcn - function to invoke -* @param thisArg - execution context for the applied function -* @returns input collection -* -* @example -* function predicate( v, key, collection ) { -* return ( v !== v ); -* } -* -* function log( v, key, collection ) { -* console.log( '%s: %d', key, v ); -* } -* -* var arr = [ 1, 2, 3, 4, NaN, 5 ]; -* -* untilEach( arr, predicate, log ); -*/ -declare function untilEach( collection: Collection, predicate: Predicate, fcn: Callback, thisArg?: any ): Collection; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = untilEach; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 1f35a3f..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s,o,i,n){var l,d;if(!r(s))throw new TypeError(e("0lxBO",s));if(!t(o))throw new TypeError(e("0lx2S",o));if(!t(i))throw new TypeError(e("0lx3Z",i));for(l=s.length,d=0;d - - - - - - Rollup Visualizer - - - -
- - - - - From b4c73b45ca7f3341e2230a9a7237935dc8f0ac2d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Apr 2023 13:18:28 +0000 Subject: [PATCH 040/135] 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 | 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 | 43 +- benchmark/benchmark.js | 89 - branches.md | 53 - docs/repl.txt | 47 - docs/types/test.ts | 71 - examples/index.js | 53 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 83 - package.json | 61 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 350 -- 37 files changed, 6203 insertions(+), 3962 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index e367e2f..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-04-01T04:18:09.390Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 038a13c..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/utils/until-each) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f023c60..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/utils/until-each) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 6610ebe..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: '35 11 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 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 + + ```
@@ -282,7 +275,7 @@ untilEach( arr, predicate, log ); ## 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]. @@ -350,9 +343,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right +[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right/tree/esm -[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each +[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 16edfdb..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var untilEach = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var sum; - var i; - - function predicate( v ) { - return isnan( v ); - } - - function fcn( v ) { - sum += v; - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - untilEach( arr, predicate, fcn ); - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::loop', function benchmark( b ) { - var sum; - var arr; - var i; - var j; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - j = 0; - while ( j < arr.length ) { - if ( isnan( arr[ j ] ) ) { - break; - } - sum += arr[ j ]; - j += 1; - } - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 3a445ad..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/utils/until-each" -%% click B href "https://github.com/stdlib-js/utils-until-each/tree/main" -%% click C href "https://github.com/stdlib-js/utils-until-each/tree/production" -%% click D href "https://github.com/stdlib-js/utils-until-each/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-until-each/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-until-each/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/until-each -[production-url]: https://github.com/stdlib-js/utils-until-each/tree/production -[deno-url]: https://github.com/stdlib-js/utils-until-each/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-until-each/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-until-each/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 11ef9f4..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,47 +0,0 @@ - -{{alias}}( collection, predicate, fcn[, thisArg] ) - Until a test condition is true, invokes a function for each element in a - collection. - - When invoked, both the predicate function and the function to apply are - provided three arguments: - - - `value`: collection value - - `index`: collection index - - `collection`: the input collection - - Parameters - ---------- - collection: Array|TypedArray|Object - Input collection over which to iterate. If provided an object, the - object must be array-like (excluding strings and functions). - - predicate: Function - The predicate function which indicates whether to stop iterating over a - collection. - - fcn: Function - The function to invoke for each element in a collection. - - thisArg: any (optional) - Execution context for the applied function. - - Returns - ------- - out: Array|TypedArray|Object - Input collection. - - Examples - -------- - > function predicate( v ) { return v !== v; }; - > function logger( v, i ) { console.log( '%s: %d', i, v ); }; - > var arr = [ 1, 2, 3, 4, NaN, 5 ]; - > {{alias}}( arr, predicate, logger ) - 0: 1 - 1: 2 - 2: 3 - 3: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 753d0bb..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,71 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 untilEach = require( './index' ); - -const log = ( v: any, index: number ): void => { - console.log( `${index}: ${v}` ); -}; - -const isNotNaN = ( v: number ): boolean => { - return ( v === v ); -}; - -// TESTS // - -// The function returns the input collection... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, log ); // $ExpectType Collection - untilEach( [ -1, 1, 2 ], isNotNaN, log, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - untilEach( 2, isNotNaN, log ); // $ExpectError - untilEach( false, isNotNaN, log ); // $ExpectError - untilEach( true, isNotNaN, log ); // $ExpectError - untilEach( {}, isNotNaN, log ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], 2, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], false, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], true, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], 'abc', log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], {}, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], [], log ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, 2 ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, false ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, true ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, 'abc' ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, {} ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - untilEach(); // $ExpectError - untilEach( [ 1, 2, 3 ] ); // $ExpectError - untilEach( [ 1, 2, 3 ], isNotNaN ); // $ExpectError - untilEach( [ 1, 2, 3 ], isNotNaN, log, {}, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index c41d90c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isEven = require( '@stdlib/assert-is-even' ).isPrimitive; -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var untilEach = require( './../lib' ); - -function predicate( value ) { - return ( value !== value ); -} - -function log( value, index, collection ) { - console.log( '%s: %d', index, value ); - if ( isEven( index ) ) { - collection.shift(); - } else { - collection.push( index+1 ); - } -} - -var arr; -var j; -var i; - -arr = new Array( 100 ); -j = floor( randu()*arr.length ); -for ( i = 0; i < arr.length; i++ ) { - if ( i === j ) { - arr[ i ] = NaN; - } else { - arr[ i ] = i; - } -} - -untilEach( arr, predicate, log ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index f0c7962..587a492 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..1f35a3f --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s,o,i,n){var l,d;if(!r(s))throw new TypeError(e("0lxBO",s));if(!t(o))throw new TypeError(e("0lx2S",o));if(!t(i))throw new TypeError(e("0lx3Z",i));for(l=s.length,d=0;d=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..cae75ac --- /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 70a1888..0000000 --- a/test/test.js +++ /dev/null @@ -1,350 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var untilEach = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof untilEach, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {}, - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( value, noop, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a predicate function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a function to invoke', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], noop, value ); - }; - } -}); - -tape( 'if provided an empty collection, the function never invokes a provided function', function test( t ) { - var arr = []; - - function predicate() { - t.fail( 'should not be invoked' ); - } - - function foo() { - t.fail( 'should not be invoked' ); - } - - untilEach( arr, predicate, foo ); - - t.deepEqual( arr, [], 'expected result' ); - t.end(); -}); - -tape( 'the function returns the input collection', function test( t ) { - var arr; - var out; - - function predicate() { - t.pass( 'invoked predicated function' ); - return false; - } - - function foo() { - t.pass( 'invoked provided function' ); - } - - arr = [ 1, 2, 3 ]; - - out = untilEach( arr, predicate, foo ); - - t.strictEqual( out, arr, 'returns input collection' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array)', function test( t ) { - var arr; - var out; - - arr = [ 1, 2, NaN, 3 ]; - out = [ 0, 0, 0, 0 ]; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - untilEach( arr, predicate, copy ); - - t.deepEqual( out, [ 1, 2, 0, 0 ], 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array-like object)', function test( t ) { - var expected; - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = { - 'length': 4, - '0': 1, - '1': 2, - '2': NaN, - '3': 3 - }; - out = { - 'length': 4, - '0': 0, - '1': 0, - '2': 0, - '3': 0 - }; - - untilEach( arr, predicate, copy ); - - expected = { - 'length': 4, - '0': 1, - '1': 2, - '2': 0, - '3': 0 - }; - - t.deepEqual( out, expected, 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (typed array)', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = new Float64Array( [ 1.0, 2.0, NaN, 3.0 ] ); - out = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - untilEach( arr, predicate, copy ); - - t.strictEqual( out[ 0 ], 1.0, 'expected result' ); - t.strictEqual( out[ 1 ], 2.0, 'expected result' ); - t.strictEqual( out[ 2 ], 0.0, 'expected result' ); - t.strictEqual( out[ 3 ], 0.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx; - var arr; - - function predicate( value ) { - return ( value !== value ); - } - - function sum( value ) { - /* eslint-disable no-invalid-this */ - this.sum += value; - this.count += 1; - } - - ctx = { - 'sum': 0, - 'count': 0 - }; - arr = [ 1.0, 2.0, 3.0 ]; - - untilEach( arr, predicate, sum, ctx ); - - t.strictEqual( ctx.sum/ctx.count, 2.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function provides basic support for dynamic arrays', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index, collection ) { - out.push( value ); - if ( index === collection.length-1 && collection.length < 10 ) { - collection.push( index+2 ); - } - } - - arr = [ 1, 2, 3 ]; - out = []; - - untilEach( arr, predicate, copy ); - - t.deepEqual( arr, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.deepEqual( out, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.end(); -}); - -tape( 'the function does not skip empty elements', function test( t ) { - var expected; - var arr; - - function predicate( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - return false; - } - - function verify( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - } - - arr = [ 1, , , 4 ]; // eslint-disable-line no-sparse-arrays - expected = [ 1, void 0, void 0, 4 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); - -tape( 'the function invokes the predicate function and the function to apply with three arguments: value, index, collection', function test( t ) { - var indices; - var values; - var arr; - - function predicate( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - return false; - } - - function verify( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - } - - arr = [ 1, 2, 3, 4 ]; - values = [ 1, 2, 3, 4 ]; - indices = [ 0, 1, 2, 3 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); From 99a39d03f11f1380689f5f1c2c6b3d1887d68c55 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 May 2023 06:09:24 +0000 Subject: [PATCH 041/135] 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 846d968..0be8304 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,13 +56,13 @@ function untilEach( collection, predicate, fcn, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); + throw new TypeError( format( '0lxBO', collection ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '0lx2S', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0lx3Z', fcn ) ); } len = collection.length; i = 0; diff --git a/package.json b/package.json index 66f6f95..129e621 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-collection": "^0.0.8", "@stdlib/assert-is-function": "^0.0.8", - "@stdlib/string-format": "^0.0.3", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2", "@stdlib/types": "^0.0.14" }, "devDependencies": { From 65e150408f0f2cbd34fa5bccebef427f91d71190 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 May 2023 12:55:49 +0000 Subject: [PATCH 042/135] Remove files --- index.d.ts | 142 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6324 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 587a492..0000000 --- a/index.d.ts +++ /dev/null @@ -1,142 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Collection } from '@stdlib/types/object'; - -/** -* Checks whether an element in a collection passes a test. -* -* @returns boolean indicating whether an element in a collection passes a test -*/ -type NullaryPredicate = () => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @returns boolean indicating whether an element in a collection passes a test -*/ -type UnaryPredicate = ( value: any ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @returns boolean indicating whether an element in a collection passes a test -*/ -type BinaryPredicate = ( value: any, index: number ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type TernaryPredicate = ( value: any, index: number, collection: Collection ) => boolean; // tslint-disable-line max-line-length - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Predicate = NullaryPredicate | UnaryPredicate | BinaryPredicate | TernaryPredicate; // tslint-disable-line max-line-length - -/** -* Function invoked for each collection element until test condition is true. -*/ -type Nullary = () => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -*/ -type Unary = ( value: any ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -*/ -type Binary = ( value: any, index: number ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Ternary = ( value: any, index: number, collection: Collection ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Until a test condition is true, invokes a function once for each element in a collection. -* -* ## Notes -* -* - When invoked, both the predicate function and the function to apply are provided three arguments: -* -* - `value`: collection value -* - `index`: collection index -* - `collection`: the input collection -* -* @param collection - input collection -* @param predicate - function which indicates whether to stop iterating over a collection -* @param fcn - function to invoke -* @param thisArg - execution context for the applied function -* @returns input collection -* -* @example -* function predicate( v, key, collection ) { -* return ( v !== v ); -* } -* -* function log( v, key, collection ) { -* console.log( '%s: %d', key, v ); -* } -* -* var arr = [ 1, 2, 3, 4, NaN, 5 ]; -* -* untilEach( arr, predicate, log ); -*/ -declare function untilEach( collection: Collection, predicate: Predicate, fcn: Callback, thisArg?: any ): Collection; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = untilEach; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 1f35a3f..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s,o,i,n){var l,d;if(!r(s))throw new TypeError(e("0lxBO",s));if(!t(o))throw new TypeError(e("0lx2S",o));if(!t(i))throw new TypeError(e("0lx3Z",i));for(l=s.length,d=0;d - - - - - - Rollup Visualizer - - - -
- - - - - From 36f9441772c958ac106155c27242abd830e532bd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 May 2023 12:56:42 +0000 Subject: [PATCH 043/135] 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 | 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 | 43 +- benchmark/benchmark.js | 89 - branches.md | 53 - docs/repl.txt | 47 - docs/types/test.ts | 71 - examples/index.js | 53 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 83 - package.json | 61 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 350 -- 37 files changed, 6203 insertions(+), 3962 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 18b5a9b..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-05-01T04:04:59.586Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 038a13c..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/utils/until-each) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f023c60..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/utils/until-each) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 6610ebe..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: '35 11 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 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 + + ```
@@ -282,7 +275,7 @@ untilEach( arr, predicate, log ); ## 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]. @@ -350,9 +343,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right +[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right/tree/esm -[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each +[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 16edfdb..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var untilEach = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var sum; - var i; - - function predicate( v ) { - return isnan( v ); - } - - function fcn( v ) { - sum += v; - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - untilEach( arr, predicate, fcn ); - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::loop', function benchmark( b ) { - var sum; - var arr; - var i; - var j; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - j = 0; - while ( j < arr.length ) { - if ( isnan( arr[ j ] ) ) { - break; - } - sum += arr[ j ]; - j += 1; - } - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 3a445ad..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/utils/until-each" -%% click B href "https://github.com/stdlib-js/utils-until-each/tree/main" -%% click C href "https://github.com/stdlib-js/utils-until-each/tree/production" -%% click D href "https://github.com/stdlib-js/utils-until-each/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-until-each/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-until-each/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/until-each -[production-url]: https://github.com/stdlib-js/utils-until-each/tree/production -[deno-url]: https://github.com/stdlib-js/utils-until-each/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-until-each/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-until-each/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 11ef9f4..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,47 +0,0 @@ - -{{alias}}( collection, predicate, fcn[, thisArg] ) - Until a test condition is true, invokes a function for each element in a - collection. - - When invoked, both the predicate function and the function to apply are - provided three arguments: - - - `value`: collection value - - `index`: collection index - - `collection`: the input collection - - Parameters - ---------- - collection: Array|TypedArray|Object - Input collection over which to iterate. If provided an object, the - object must be array-like (excluding strings and functions). - - predicate: Function - The predicate function which indicates whether to stop iterating over a - collection. - - fcn: Function - The function to invoke for each element in a collection. - - thisArg: any (optional) - Execution context for the applied function. - - Returns - ------- - out: Array|TypedArray|Object - Input collection. - - Examples - -------- - > function predicate( v ) { return v !== v; }; - > function logger( v, i ) { console.log( '%s: %d', i, v ); }; - > var arr = [ 1, 2, 3, 4, NaN, 5 ]; - > {{alias}}( arr, predicate, logger ) - 0: 1 - 1: 2 - 2: 3 - 3: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 753d0bb..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,71 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 untilEach = require( './index' ); - -const log = ( v: any, index: number ): void => { - console.log( `${index}: ${v}` ); -}; - -const isNotNaN = ( v: number ): boolean => { - return ( v === v ); -}; - -// TESTS // - -// The function returns the input collection... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, log ); // $ExpectType Collection - untilEach( [ -1, 1, 2 ], isNotNaN, log, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - untilEach( 2, isNotNaN, log ); // $ExpectError - untilEach( false, isNotNaN, log ); // $ExpectError - untilEach( true, isNotNaN, log ); // $ExpectError - untilEach( {}, isNotNaN, log ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], 2, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], false, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], true, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], 'abc', log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], {}, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], [], log ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, 2 ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, false ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, true ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, 'abc' ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, {} ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - untilEach(); // $ExpectError - untilEach( [ 1, 2, 3 ] ); // $ExpectError - untilEach( [ 1, 2, 3 ], isNotNaN ); // $ExpectError - untilEach( [ 1, 2, 3 ], isNotNaN, log, {}, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index c41d90c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isEven = require( '@stdlib/assert-is-even' ).isPrimitive; -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var untilEach = require( './../lib' ); - -function predicate( value ) { - return ( value !== value ); -} - -function log( value, index, collection ) { - console.log( '%s: %d', index, value ); - if ( isEven( index ) ) { - collection.shift(); - } else { - collection.push( index+1 ); - } -} - -var arr; -var j; -var i; - -arr = new Array( 100 ); -j = floor( randu()*arr.length ); -for ( i = 0; i < arr.length; i++ ) { - if ( i === j ) { - arr[ i ] = NaN; - } else { - arr[ i ] = i; - } -} - -untilEach( arr, predicate, log ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index f0c7962..587a492 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..1f35a3f --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s,o,i,n){var l,d;if(!r(s))throw new TypeError(e("0lxBO",s));if(!t(o))throw new TypeError(e("0lx2S",o));if(!t(i))throw new TypeError(e("0lx3Z",i));for(l=s.length,d=0;d=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..3bf03bb --- /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 70a1888..0000000 --- a/test/test.js +++ /dev/null @@ -1,350 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var untilEach = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof untilEach, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {}, - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( value, noop, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a predicate function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a function to invoke', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], noop, value ); - }; - } -}); - -tape( 'if provided an empty collection, the function never invokes a provided function', function test( t ) { - var arr = []; - - function predicate() { - t.fail( 'should not be invoked' ); - } - - function foo() { - t.fail( 'should not be invoked' ); - } - - untilEach( arr, predicate, foo ); - - t.deepEqual( arr, [], 'expected result' ); - t.end(); -}); - -tape( 'the function returns the input collection', function test( t ) { - var arr; - var out; - - function predicate() { - t.pass( 'invoked predicated function' ); - return false; - } - - function foo() { - t.pass( 'invoked provided function' ); - } - - arr = [ 1, 2, 3 ]; - - out = untilEach( arr, predicate, foo ); - - t.strictEqual( out, arr, 'returns input collection' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array)', function test( t ) { - var arr; - var out; - - arr = [ 1, 2, NaN, 3 ]; - out = [ 0, 0, 0, 0 ]; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - untilEach( arr, predicate, copy ); - - t.deepEqual( out, [ 1, 2, 0, 0 ], 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array-like object)', function test( t ) { - var expected; - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = { - 'length': 4, - '0': 1, - '1': 2, - '2': NaN, - '3': 3 - }; - out = { - 'length': 4, - '0': 0, - '1': 0, - '2': 0, - '3': 0 - }; - - untilEach( arr, predicate, copy ); - - expected = { - 'length': 4, - '0': 1, - '1': 2, - '2': 0, - '3': 0 - }; - - t.deepEqual( out, expected, 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (typed array)', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = new Float64Array( [ 1.0, 2.0, NaN, 3.0 ] ); - out = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - untilEach( arr, predicate, copy ); - - t.strictEqual( out[ 0 ], 1.0, 'expected result' ); - t.strictEqual( out[ 1 ], 2.0, 'expected result' ); - t.strictEqual( out[ 2 ], 0.0, 'expected result' ); - t.strictEqual( out[ 3 ], 0.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx; - var arr; - - function predicate( value ) { - return ( value !== value ); - } - - function sum( value ) { - /* eslint-disable no-invalid-this */ - this.sum += value; - this.count += 1; - } - - ctx = { - 'sum': 0, - 'count': 0 - }; - arr = [ 1.0, 2.0, 3.0 ]; - - untilEach( arr, predicate, sum, ctx ); - - t.strictEqual( ctx.sum/ctx.count, 2.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function provides basic support for dynamic arrays', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index, collection ) { - out.push( value ); - if ( index === collection.length-1 && collection.length < 10 ) { - collection.push( index+2 ); - } - } - - arr = [ 1, 2, 3 ]; - out = []; - - untilEach( arr, predicate, copy ); - - t.deepEqual( arr, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.deepEqual( out, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.end(); -}); - -tape( 'the function does not skip empty elements', function test( t ) { - var expected; - var arr; - - function predicate( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - return false; - } - - function verify( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - } - - arr = [ 1, , , 4 ]; // eslint-disable-line no-sparse-arrays - expected = [ 1, void 0, void 0, 4 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); - -tape( 'the function invokes the predicate function and the function to apply with three arguments: value, index, collection', function test( t ) { - var indices; - var values; - var arr; - - function predicate( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - return false; - } - - function verify( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - } - - arr = [ 1, 2, 3, 4 ]; - values = [ 1, 2, 3, 4 ]; - indices = [ 0, 1, 2, 3 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); From a028ab89c8688e0a897df63cafe8ef5344f39542 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Jun 2023 05:48:33 +0000 Subject: [PATCH 044/135] 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 846d968..0be8304 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,13 +56,13 @@ function untilEach( collection, predicate, fcn, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); + throw new TypeError( format( '0lxBO', collection ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '0lx2S', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0lx3Z', fcn ) ); } len = collection.length; i = 0; diff --git a/package.json b/package.json index 66f6f95..129e621 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-collection": "^0.0.8", "@stdlib/assert-is-function": "^0.0.8", - "@stdlib/string-format": "^0.0.3", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2", "@stdlib/types": "^0.0.14" }, "devDependencies": { From fd607d2e5daf0241f350a41f402440193456697e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Jun 2023 13:16:33 +0000 Subject: [PATCH 045/135] Remove files --- index.d.ts | 142 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6324 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 587a492..0000000 --- a/index.d.ts +++ /dev/null @@ -1,142 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Collection } from '@stdlib/types/object'; - -/** -* Checks whether an element in a collection passes a test. -* -* @returns boolean indicating whether an element in a collection passes a test -*/ -type NullaryPredicate = () => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @returns boolean indicating whether an element in a collection passes a test -*/ -type UnaryPredicate = ( value: any ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @returns boolean indicating whether an element in a collection passes a test -*/ -type BinaryPredicate = ( value: any, index: number ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type TernaryPredicate = ( value: any, index: number, collection: Collection ) => boolean; // tslint-disable-line max-line-length - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Predicate = NullaryPredicate | UnaryPredicate | BinaryPredicate | TernaryPredicate; // tslint-disable-line max-line-length - -/** -* Function invoked for each collection element until test condition is true. -*/ -type Nullary = () => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -*/ -type Unary = ( value: any ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -*/ -type Binary = ( value: any, index: number ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Ternary = ( value: any, index: number, collection: Collection ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Until a test condition is true, invokes a function once for each element in a collection. -* -* ## Notes -* -* - When invoked, both the predicate function and the function to apply are provided three arguments: -* -* - `value`: collection value -* - `index`: collection index -* - `collection`: the input collection -* -* @param collection - input collection -* @param predicate - function which indicates whether to stop iterating over a collection -* @param fcn - function to invoke -* @param thisArg - execution context for the applied function -* @returns input collection -* -* @example -* function predicate( v, key, collection ) { -* return ( v !== v ); -* } -* -* function log( v, key, collection ) { -* console.log( '%s: %d', key, v ); -* } -* -* var arr = [ 1, 2, 3, 4, NaN, 5 ]; -* -* untilEach( arr, predicate, log ); -*/ -declare function untilEach( collection: Collection, predicate: Predicate, fcn: Callback, thisArg?: any ): Collection; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = untilEach; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 1f35a3f..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s,o,i,n){var l,d;if(!r(s))throw new TypeError(e("0lxBO",s));if(!t(o))throw new TypeError(e("0lx2S",o));if(!t(i))throw new TypeError(e("0lx3Z",i));for(l=s.length,d=0;d - - - - - - Rollup Visualizer - - - -
- - - - - From 40d23b58f9f95a282acd74af1aa8c70fed67b317 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Jun 2023 13:18:01 +0000 Subject: [PATCH 046/135] 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 | 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 | 43 +- benchmark/benchmark.js | 89 - branches.md | 53 - docs/repl.txt | 47 - docs/types/test.ts | 71 - examples/index.js | 53 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 83 - package.json | 61 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 350 -- 37 files changed, 6203 insertions(+), 3962 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 2d50941..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-06-01T03:46:10.004Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 038a13c..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/utils/until-each) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f023c60..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/utils/until-each) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 6610ebe..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: '35 11 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 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 + + ```
@@ -282,7 +275,7 @@ untilEach( arr, predicate, log ); ## 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]. @@ -350,9 +343,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right +[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right/tree/esm -[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each +[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 16edfdb..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var untilEach = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var sum; - var i; - - function predicate( v ) { - return isnan( v ); - } - - function fcn( v ) { - sum += v; - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - untilEach( arr, predicate, fcn ); - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::loop', function benchmark( b ) { - var sum; - var arr; - var i; - var j; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - j = 0; - while ( j < arr.length ) { - if ( isnan( arr[ j ] ) ) { - break; - } - sum += arr[ j ]; - j += 1; - } - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 3a445ad..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/utils/until-each" -%% click B href "https://github.com/stdlib-js/utils-until-each/tree/main" -%% click C href "https://github.com/stdlib-js/utils-until-each/tree/production" -%% click D href "https://github.com/stdlib-js/utils-until-each/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-until-each/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-until-each/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/until-each -[production-url]: https://github.com/stdlib-js/utils-until-each/tree/production -[deno-url]: https://github.com/stdlib-js/utils-until-each/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-until-each/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-until-each/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 11ef9f4..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,47 +0,0 @@ - -{{alias}}( collection, predicate, fcn[, thisArg] ) - Until a test condition is true, invokes a function for each element in a - collection. - - When invoked, both the predicate function and the function to apply are - provided three arguments: - - - `value`: collection value - - `index`: collection index - - `collection`: the input collection - - Parameters - ---------- - collection: Array|TypedArray|Object - Input collection over which to iterate. If provided an object, the - object must be array-like (excluding strings and functions). - - predicate: Function - The predicate function which indicates whether to stop iterating over a - collection. - - fcn: Function - The function to invoke for each element in a collection. - - thisArg: any (optional) - Execution context for the applied function. - - Returns - ------- - out: Array|TypedArray|Object - Input collection. - - Examples - -------- - > function predicate( v ) { return v !== v; }; - > function logger( v, i ) { console.log( '%s: %d', i, v ); }; - > var arr = [ 1, 2, 3, 4, NaN, 5 ]; - > {{alias}}( arr, predicate, logger ) - 0: 1 - 1: 2 - 2: 3 - 3: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 753d0bb..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,71 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 untilEach = require( './index' ); - -const log = ( v: any, index: number ): void => { - console.log( `${index}: ${v}` ); -}; - -const isNotNaN = ( v: number ): boolean => { - return ( v === v ); -}; - -// TESTS // - -// The function returns the input collection... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, log ); // $ExpectType Collection - untilEach( [ -1, 1, 2 ], isNotNaN, log, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - untilEach( 2, isNotNaN, log ); // $ExpectError - untilEach( false, isNotNaN, log ); // $ExpectError - untilEach( true, isNotNaN, log ); // $ExpectError - untilEach( {}, isNotNaN, log ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], 2, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], false, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], true, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], 'abc', log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], {}, log ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], [], log ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, 2 ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, false ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, true ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, 'abc' ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, {} ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isNotNaN, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - untilEach(); // $ExpectError - untilEach( [ 1, 2, 3 ] ); // $ExpectError - untilEach( [ 1, 2, 3 ], isNotNaN ); // $ExpectError - untilEach( [ 1, 2, 3 ], isNotNaN, log, {}, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index c41d90c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isEven = require( '@stdlib/assert-is-even' ).isPrimitive; -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var untilEach = require( './../lib' ); - -function predicate( value ) { - return ( value !== value ); -} - -function log( value, index, collection ) { - console.log( '%s: %d', index, value ); - if ( isEven( index ) ) { - collection.shift(); - } else { - collection.push( index+1 ); - } -} - -var arr; -var j; -var i; - -arr = new Array( 100 ); -j = floor( randu()*arr.length ); -for ( i = 0; i < arr.length; i++ ) { - if ( i === j ) { - arr[ i ] = NaN; - } else { - arr[ i ] = i; - } -} - -untilEach( arr, predicate, log ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index f0c7962..587a492 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..1f35a3f --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s,o,i,n){var l,d;if(!r(s))throw new TypeError(e("0lxBO",s));if(!t(o))throw new TypeError(e("0lx2S",o));if(!t(i))throw new TypeError(e("0lx3Z",i));for(l=s.length,d=0;d=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..75caf8d --- /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 70a1888..0000000 --- a/test/test.js +++ /dev/null @@ -1,350 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var untilEach = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof untilEach, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {}, - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( value, noop, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a predicate function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a function to invoke', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], noop, value ); - }; - } -}); - -tape( 'if provided an empty collection, the function never invokes a provided function', function test( t ) { - var arr = []; - - function predicate() { - t.fail( 'should not be invoked' ); - } - - function foo() { - t.fail( 'should not be invoked' ); - } - - untilEach( arr, predicate, foo ); - - t.deepEqual( arr, [], 'expected result' ); - t.end(); -}); - -tape( 'the function returns the input collection', function test( t ) { - var arr; - var out; - - function predicate() { - t.pass( 'invoked predicated function' ); - return false; - } - - function foo() { - t.pass( 'invoked provided function' ); - } - - arr = [ 1, 2, 3 ]; - - out = untilEach( arr, predicate, foo ); - - t.strictEqual( out, arr, 'returns input collection' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array)', function test( t ) { - var arr; - var out; - - arr = [ 1, 2, NaN, 3 ]; - out = [ 0, 0, 0, 0 ]; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - untilEach( arr, predicate, copy ); - - t.deepEqual( out, [ 1, 2, 0, 0 ], 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array-like object)', function test( t ) { - var expected; - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = { - 'length': 4, - '0': 1, - '1': 2, - '2': NaN, - '3': 3 - }; - out = { - 'length': 4, - '0': 0, - '1': 0, - '2': 0, - '3': 0 - }; - - untilEach( arr, predicate, copy ); - - expected = { - 'length': 4, - '0': 1, - '1': 2, - '2': 0, - '3': 0 - }; - - t.deepEqual( out, expected, 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (typed array)', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = new Float64Array( [ 1.0, 2.0, NaN, 3.0 ] ); - out = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - untilEach( arr, predicate, copy ); - - t.strictEqual( out[ 0 ], 1.0, 'expected result' ); - t.strictEqual( out[ 1 ], 2.0, 'expected result' ); - t.strictEqual( out[ 2 ], 0.0, 'expected result' ); - t.strictEqual( out[ 3 ], 0.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx; - var arr; - - function predicate( value ) { - return ( value !== value ); - } - - function sum( value ) { - /* eslint-disable no-invalid-this */ - this.sum += value; - this.count += 1; - } - - ctx = { - 'sum': 0, - 'count': 0 - }; - arr = [ 1.0, 2.0, 3.0 ]; - - untilEach( arr, predicate, sum, ctx ); - - t.strictEqual( ctx.sum/ctx.count, 2.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function provides basic support for dynamic arrays', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index, collection ) { - out.push( value ); - if ( index === collection.length-1 && collection.length < 10 ) { - collection.push( index+2 ); - } - } - - arr = [ 1, 2, 3 ]; - out = []; - - untilEach( arr, predicate, copy ); - - t.deepEqual( arr, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.deepEqual( out, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.end(); -}); - -tape( 'the function does not skip empty elements', function test( t ) { - var expected; - var arr; - - function predicate( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - return false; - } - - function verify( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - } - - arr = [ 1, , , 4 ]; // eslint-disable-line no-sparse-arrays - expected = [ 1, void 0, void 0, 4 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); - -tape( 'the function invokes the predicate function and the function to apply with three arguments: value, index, collection', function test( t ) { - var indices; - var values; - var arr; - - function predicate( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - return false; - } - - function verify( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - } - - arr = [ 1, 2, 3, 4 ]; - values = [ 1, 2, 3, 4 ]; - indices = [ 0, 1, 2, 3 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); From 71409e9c30b195178875321b36a17c485f6cc320 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 27 Jun 2023 19:26:34 +0000 Subject: [PATCH 047/135] 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 846d968..0be8304 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,13 +56,13 @@ function untilEach( collection, predicate, fcn, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); + throw new TypeError( format( '0lxBO', collection ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '0lx2S', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0lx3Z', fcn ) ); } len = collection.length; i = 0; diff --git a/package.json b/package.json index 66f6f95..129e621 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-collection": "^0.0.8", "@stdlib/assert-is-function": "^0.0.8", - "@stdlib/string-format": "^0.0.3", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2", "@stdlib/types": "^0.0.14" }, "devDependencies": { From 12666ec6b4233439bbcefe0a50371658d3743315 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 27 Jun 2023 19:27:02 +0000 Subject: [PATCH 048/135] Remove files --- index.d.ts | 142 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6324 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 587a492..0000000 --- a/index.d.ts +++ /dev/null @@ -1,142 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Collection } from '@stdlib/types/object'; - -/** -* Checks whether an element in a collection passes a test. -* -* @returns boolean indicating whether an element in a collection passes a test -*/ -type NullaryPredicate = () => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @returns boolean indicating whether an element in a collection passes a test -*/ -type UnaryPredicate = ( value: any ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @returns boolean indicating whether an element in a collection passes a test -*/ -type BinaryPredicate = ( value: any, index: number ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type TernaryPredicate = ( value: any, index: number, collection: Collection ) => boolean; // tslint-disable-line max-line-length - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Predicate = NullaryPredicate | UnaryPredicate | BinaryPredicate | TernaryPredicate; // tslint-disable-line max-line-length - -/** -* Function invoked for each collection element until test condition is true. -*/ -type Nullary = () => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -*/ -type Unary = ( value: any ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -*/ -type Binary = ( value: any, index: number ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Ternary = ( value: any, index: number, collection: Collection ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Until a test condition is true, invokes a function once for each element in a collection. -* -* ## Notes -* -* - When invoked, both the predicate function and the function to apply are provided three arguments: -* -* - `value`: collection value -* - `index`: collection index -* - `collection`: the input collection -* -* @param collection - input collection -* @param predicate - function which indicates whether to stop iterating over a collection -* @param fcn - function to invoke -* @param thisArg - execution context for the applied function -* @returns input collection -* -* @example -* function predicate( v, key, collection ) { -* return ( v !== v ); -* } -* -* function log( v, key, collection ) { -* console.log( '%s: %d', key, v ); -* } -* -* var arr = [ 1, 2, 3, 4, NaN, 5 ]; -* -* untilEach( arr, predicate, log ); -*/ -declare function untilEach( collection: Collection, predicate: Predicate, fcn: Callback, thisArg?: any ): Collection; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = untilEach; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 1f35a3f..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s,o,i,n){var l,d;if(!r(s))throw new TypeError(e("0lxBO",s));if(!t(o))throw new TypeError(e("0lx2S",o));if(!t(i))throw new TypeError(e("0lx3Z",i));for(l=s.length,d=0;d - - - - - - Rollup Visualizer - - - -
- - - - - From 198406c38c3fba7ae2a8131213d35f915f26ee51 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 27 Jun 2023 19:28:03 +0000 Subject: [PATCH 049/135] 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 | 43 +- benchmark/benchmark.js | 89 - branches.md | 53 - docs/repl.txt | 47 - docs/types/test.ts | 89 - examples/index.js | 53 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 83 - package.json | 61 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 350 -- 36 files changed, 6203 insertions(+), 3979 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 038a13c..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/utils/until-each) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f023c60..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/utils/until-each) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 6610ebe..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: '35 11 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 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 + + ```
@@ -282,7 +275,7 @@ untilEach( arr, predicate, log ); ## 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]. @@ -350,9 +343,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right +[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right/tree/esm -[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each +[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 16edfdb..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var untilEach = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var sum; - var i; - - function predicate( v ) { - return isnan( v ); - } - - function fcn( v ) { - sum += v; - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - untilEach( arr, predicate, fcn ); - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::loop', function benchmark( b ) { - var sum; - var arr; - var i; - var j; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - j = 0; - while ( j < arr.length ) { - if ( isnan( arr[ j ] ) ) { - break; - } - sum += arr[ j ]; - j += 1; - } - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 3a445ad..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/utils/until-each" -%% click B href "https://github.com/stdlib-js/utils-until-each/tree/main" -%% click C href "https://github.com/stdlib-js/utils-until-each/tree/production" -%% click D href "https://github.com/stdlib-js/utils-until-each/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-until-each/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-until-each/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/until-each -[production-url]: https://github.com/stdlib-js/utils-until-each/tree/production -[deno-url]: https://github.com/stdlib-js/utils-until-each/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-until-each/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-until-each/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 11ef9f4..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,47 +0,0 @@ - -{{alias}}( collection, predicate, fcn[, thisArg] ) - Until a test condition is true, invokes a function for each element in a - collection. - - When invoked, both the predicate function and the function to apply are - provided three arguments: - - - `value`: collection value - - `index`: collection index - - `collection`: the input collection - - Parameters - ---------- - collection: Array|TypedArray|Object - Input collection over which to iterate. If provided an object, the - object must be array-like (excluding strings and functions). - - predicate: Function - The predicate function which indicates whether to stop iterating over a - collection. - - fcn: Function - The function to invoke for each element in a collection. - - thisArg: any (optional) - Execution context for the applied function. - - Returns - ------- - out: Array|TypedArray|Object - Input collection. - - Examples - -------- - > function predicate( v ) { return v !== v; }; - > function logger( v, i ) { console.log( '%s: %d', i, v ); }; - > var arr = [ 1, 2, 3, 4, NaN, 5 ]; - > {{alias}}( arr, predicate, logger ) - 0: 1 - 1: 2 - 2: 3 - 3: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4833283..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,89 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 untilEach = require( './index' ); - -/** -* Test function. -* -* @param v - value -* @param index - index -*/ -function fcn( v: number, index: number ): void { - if ( v !== v ) { - throw new Error( 'beep' ); - } - if ( index !== index ) { - throw new Error( 'beep' ); - } -} - -/** -* Test function. -* -* @param v - value -* @returns result -*/ -function isnan( v: number ): boolean { - return ( v !== v ); -} - - -// TESTS // - -// The function returns the input collection... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, fcn ); // $ExpectType Collection - untilEach( [ -1, 1, 2 ], isnan, fcn, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - untilEach( 2, isnan, fcn ); // $ExpectError - untilEach( false, isnan, fcn ); // $ExpectError - untilEach( true, isnan, fcn ); // $ExpectError - untilEach( {}, isnan, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], 2, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], false, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], true, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], 'abc', fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], {}, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], [], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, 2 ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, false ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, true ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, 'abc' ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, {} ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - untilEach(); // $ExpectError - untilEach( [ 1, 2, 3 ] ); // $ExpectError - untilEach( [ 1, 2, 3 ], isnan ); // $ExpectError - untilEach( [ 1, 2, 3 ], isnan, fcn, {}, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index c41d90c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isEven = require( '@stdlib/assert-is-even' ).isPrimitive; -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var untilEach = require( './../lib' ); - -function predicate( value ) { - return ( value !== value ); -} - -function log( value, index, collection ) { - console.log( '%s: %d', index, value ); - if ( isEven( index ) ) { - collection.shift(); - } else { - collection.push( index+1 ); - } -} - -var arr; -var j; -var i; - -arr = new Array( 100 ); -j = floor( randu()*arr.length ); -for ( i = 0; i < arr.length; i++ ) { - if ( i === j ) { - arr[ i ] = NaN; - } else { - arr[ i ] = i; - } -} - -untilEach( arr, predicate, log ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index b8f0885..bb940c1 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..1f35a3f --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s,o,i,n){var l,d;if(!r(s))throw new TypeError(e("0lxBO",s));if(!t(o))throw new TypeError(e("0lx2S",o));if(!t(i))throw new TypeError(e("0lx3Z",i));for(l=s.length,d=0;d=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..8c6e060 --- /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 70a1888..0000000 --- a/test/test.js +++ /dev/null @@ -1,350 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var untilEach = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof untilEach, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {}, - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( value, noop, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a predicate function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a function to invoke', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], noop, value ); - }; - } -}); - -tape( 'if provided an empty collection, the function never invokes a provided function', function test( t ) { - var arr = []; - - function predicate() { - t.fail( 'should not be invoked' ); - } - - function foo() { - t.fail( 'should not be invoked' ); - } - - untilEach( arr, predicate, foo ); - - t.deepEqual( arr, [], 'expected result' ); - t.end(); -}); - -tape( 'the function returns the input collection', function test( t ) { - var arr; - var out; - - function predicate() { - t.pass( 'invoked predicated function' ); - return false; - } - - function foo() { - t.pass( 'invoked provided function' ); - } - - arr = [ 1, 2, 3 ]; - - out = untilEach( arr, predicate, foo ); - - t.strictEqual( out, arr, 'returns input collection' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array)', function test( t ) { - var arr; - var out; - - arr = [ 1, 2, NaN, 3 ]; - out = [ 0, 0, 0, 0 ]; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - untilEach( arr, predicate, copy ); - - t.deepEqual( out, [ 1, 2, 0, 0 ], 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array-like object)', function test( t ) { - var expected; - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = { - 'length': 4, - '0': 1, - '1': 2, - '2': NaN, - '3': 3 - }; - out = { - 'length': 4, - '0': 0, - '1': 0, - '2': 0, - '3': 0 - }; - - untilEach( arr, predicate, copy ); - - expected = { - 'length': 4, - '0': 1, - '1': 2, - '2': 0, - '3': 0 - }; - - t.deepEqual( out, expected, 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (typed array)', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = new Float64Array( [ 1.0, 2.0, NaN, 3.0 ] ); - out = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - untilEach( arr, predicate, copy ); - - t.strictEqual( out[ 0 ], 1.0, 'expected result' ); - t.strictEqual( out[ 1 ], 2.0, 'expected result' ); - t.strictEqual( out[ 2 ], 0.0, 'expected result' ); - t.strictEqual( out[ 3 ], 0.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx; - var arr; - - function predicate( value ) { - return ( value !== value ); - } - - function sum( value ) { - /* eslint-disable no-invalid-this */ - this.sum += value; - this.count += 1; - } - - ctx = { - 'sum': 0, - 'count': 0 - }; - arr = [ 1.0, 2.0, 3.0 ]; - - untilEach( arr, predicate, sum, ctx ); - - t.strictEqual( ctx.sum/ctx.count, 2.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function provides basic support for dynamic arrays', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index, collection ) { - out.push( value ); - if ( index === collection.length-1 && collection.length < 10 ) { - collection.push( index+2 ); - } - } - - arr = [ 1, 2, 3 ]; - out = []; - - untilEach( arr, predicate, copy ); - - t.deepEqual( arr, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.deepEqual( out, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.end(); -}); - -tape( 'the function does not skip empty elements', function test( t ) { - var expected; - var arr; - - function predicate( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - return false; - } - - function verify( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - } - - arr = [ 1, , , 4 ]; // eslint-disable-line no-sparse-arrays - expected = [ 1, void 0, void 0, 4 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); - -tape( 'the function invokes the predicate function and the function to apply with three arguments: value, index, collection', function test( t ) { - var indices; - var values; - var arr; - - function predicate( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - return false; - } - - function verify( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - } - - arr = [ 1, 2, 3, 4 ]; - values = [ 1, 2, 3, 4 ]; - indices = [ 0, 1, 2, 3 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); From 5da2c59e107702426a31a7fd2dab7f0efe750636 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jul 2023 05:51:43 +0000 Subject: [PATCH 050/135] 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 846d968..0be8304 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,13 +56,13 @@ function untilEach( collection, predicate, fcn, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); + throw new TypeError( format( '0lxBO', collection ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '0lx2S', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0lx3Z', fcn ) ); } len = collection.length; i = 0; diff --git a/package.json b/package.json index 66f6f95..129e621 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-collection": "^0.0.8", "@stdlib/assert-is-function": "^0.0.8", - "@stdlib/string-format": "^0.0.3", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2", "@stdlib/types": "^0.0.14" }, "devDependencies": { From 5b163d8acef69d058305c7d33581a280a72db3f6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jul 2023 13:29:36 +0000 Subject: [PATCH 051/135] Remove files --- index.d.ts | 142 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6324 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 bb940c1..0000000 --- a/index.d.ts +++ /dev/null @@ -1,142 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/object'; - -/** -* Checks whether an element in a collection passes a test. -* -* @returns boolean indicating whether an element in a collection passes a test -*/ -type NullaryPredicate = () => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @returns boolean indicating whether an element in a collection passes a test -*/ -type UnaryPredicate = ( value: T ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @returns boolean indicating whether an element in a collection passes a test -*/ -type BinaryPredicate = ( value: T, index: number ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type TernaryPredicate = ( value: T, index: number, collection: Collection ) => boolean; // tslint-disable-line max-line-length - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Predicate = NullaryPredicate | UnaryPredicate | BinaryPredicate | TernaryPredicate; // tslint-disable-line max-line-length - -/** -* Function invoked for each collection element until test condition is true. -*/ -type Nullary = () => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -*/ -type Unary = ( value: T ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -*/ -type Binary = ( value: T, index: number ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Ternary = ( value: T, index: number, collection: Collection ) => void; // tslint-disable-line max-line-length - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Until a test condition is true, invokes a function once for each element in a collection. -* -* ## Notes -* -* - When invoked, both the predicate function and the function to apply are provided three arguments: -* -* - `value`: collection value -* - `index`: collection index -* - `collection`: the input collection -* -* @param collection - input collection -* @param predicate - function which indicates whether to stop iterating over a collection -* @param fcn - function to invoke -* @param thisArg - execution context for the applied function -* @returns input collection -* -* @example -* function predicate( v, key, collection ) { -* return ( v !== v ); -* } -* -* function log( v, key, collection ) { -* console.log( '%s: %d', key, v ); -* } -* -* var arr = [ 1, 2, 3, 4, NaN, 5 ]; -* -* untilEach( arr, predicate, log ); -*/ -declare function untilEach( collection: Collection, predicate: Predicate, fcn: Callback, thisArg?: any ): Collection; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = untilEach; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 1f35a3f..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s,o,i,n){var l,d;if(!r(s))throw new TypeError(e("0lxBO",s));if(!t(o))throw new TypeError(e("0lx2S",o));if(!t(i))throw new TypeError(e("0lx3Z",i));for(l=s.length,d=0;d - - - - - - Rollup Visualizer - - - -
- - - - - From c2aed228ebb54f9908b3ea0e038bfb2693283f44 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jul 2023 13:30:34 +0000 Subject: [PATCH 052/135] 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 | 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 | 43 +- benchmark/benchmark.js | 89 - branches.md | 53 - docs/repl.txt | 47 - docs/types/test.ts | 89 - examples/index.js | 53 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 83 - package.json | 61 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 350 -- 37 files changed, 6203 insertions(+), 3980 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 6df2b93..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-07-01T03:46:57.466Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 038a13c..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/utils/until-each) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f023c60..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/utils/until-each) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 6610ebe..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: '35 11 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 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 + + ```
@@ -282,7 +275,7 @@ untilEach( arr, predicate, log ); ## 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]. @@ -350,9 +343,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right +[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right/tree/esm -[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each +[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 16edfdb..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var untilEach = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var sum; - var i; - - function predicate( v ) { - return isnan( v ); - } - - function fcn( v ) { - sum += v; - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - untilEach( arr, predicate, fcn ); - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::loop', function benchmark( b ) { - var sum; - var arr; - var i; - var j; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - j = 0; - while ( j < arr.length ) { - if ( isnan( arr[ j ] ) ) { - break; - } - sum += arr[ j ]; - j += 1; - } - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 3a445ad..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/utils/until-each" -%% click B href "https://github.com/stdlib-js/utils-until-each/tree/main" -%% click C href "https://github.com/stdlib-js/utils-until-each/tree/production" -%% click D href "https://github.com/stdlib-js/utils-until-each/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-until-each/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-until-each/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/until-each -[production-url]: https://github.com/stdlib-js/utils-until-each/tree/production -[deno-url]: https://github.com/stdlib-js/utils-until-each/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-until-each/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-until-each/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 11ef9f4..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,47 +0,0 @@ - -{{alias}}( collection, predicate, fcn[, thisArg] ) - Until a test condition is true, invokes a function for each element in a - collection. - - When invoked, both the predicate function and the function to apply are - provided three arguments: - - - `value`: collection value - - `index`: collection index - - `collection`: the input collection - - Parameters - ---------- - collection: Array|TypedArray|Object - Input collection over which to iterate. If provided an object, the - object must be array-like (excluding strings and functions). - - predicate: Function - The predicate function which indicates whether to stop iterating over a - collection. - - fcn: Function - The function to invoke for each element in a collection. - - thisArg: any (optional) - Execution context for the applied function. - - Returns - ------- - out: Array|TypedArray|Object - Input collection. - - Examples - -------- - > function predicate( v ) { return v !== v; }; - > function logger( v, i ) { console.log( '%s: %d', i, v ); }; - > var arr = [ 1, 2, 3, 4, NaN, 5 ]; - > {{alias}}( arr, predicate, logger ) - 0: 1 - 1: 2 - 2: 3 - 3: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4833283..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,89 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 untilEach = require( './index' ); - -/** -* Test function. -* -* @param v - value -* @param index - index -*/ -function fcn( v: number, index: number ): void { - if ( v !== v ) { - throw new Error( 'beep' ); - } - if ( index !== index ) { - throw new Error( 'beep' ); - } -} - -/** -* Test function. -* -* @param v - value -* @returns result -*/ -function isnan( v: number ): boolean { - return ( v !== v ); -} - - -// TESTS // - -// The function returns the input collection... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, fcn ); // $ExpectType Collection - untilEach( [ -1, 1, 2 ], isnan, fcn, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - untilEach( 2, isnan, fcn ); // $ExpectError - untilEach( false, isnan, fcn ); // $ExpectError - untilEach( true, isnan, fcn ); // $ExpectError - untilEach( {}, isnan, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], 2, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], false, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], true, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], 'abc', fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], {}, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], [], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, 2 ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, false ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, true ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, 'abc' ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, {} ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - untilEach(); // $ExpectError - untilEach( [ 1, 2, 3 ] ); // $ExpectError - untilEach( [ 1, 2, 3 ], isnan ); // $ExpectError - untilEach( [ 1, 2, 3 ], isnan, fcn, {}, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index c41d90c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isEven = require( '@stdlib/assert-is-even' ).isPrimitive; -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var untilEach = require( './../lib' ); - -function predicate( value ) { - return ( value !== value ); -} - -function log( value, index, collection ) { - console.log( '%s: %d', index, value ); - if ( isEven( index ) ) { - collection.shift(); - } else { - collection.push( index+1 ); - } -} - -var arr; -var j; -var i; - -arr = new Array( 100 ); -j = floor( randu()*arr.length ); -for ( i = 0; i < arr.length; i++ ) { - if ( i === j ) { - arr[ i ] = NaN; - } else { - arr[ i ] = i; - } -} - -untilEach( arr, predicate, log ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index b8f0885..bb940c1 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..1f35a3f --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s,o,i,n){var l,d;if(!r(s))throw new TypeError(e("0lxBO",s));if(!t(o))throw new TypeError(e("0lx2S",o));if(!t(i))throw new TypeError(e("0lx3Z",i));for(l=s.length,d=0;d=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..a9c97d4 --- /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 70a1888..0000000 --- a/test/test.js +++ /dev/null @@ -1,350 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var untilEach = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof untilEach, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {}, - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( value, noop, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a predicate function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a function to invoke', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], noop, value ); - }; - } -}); - -tape( 'if provided an empty collection, the function never invokes a provided function', function test( t ) { - var arr = []; - - function predicate() { - t.fail( 'should not be invoked' ); - } - - function foo() { - t.fail( 'should not be invoked' ); - } - - untilEach( arr, predicate, foo ); - - t.deepEqual( arr, [], 'expected result' ); - t.end(); -}); - -tape( 'the function returns the input collection', function test( t ) { - var arr; - var out; - - function predicate() { - t.pass( 'invoked predicated function' ); - return false; - } - - function foo() { - t.pass( 'invoked provided function' ); - } - - arr = [ 1, 2, 3 ]; - - out = untilEach( arr, predicate, foo ); - - t.strictEqual( out, arr, 'returns input collection' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array)', function test( t ) { - var arr; - var out; - - arr = [ 1, 2, NaN, 3 ]; - out = [ 0, 0, 0, 0 ]; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - untilEach( arr, predicate, copy ); - - t.deepEqual( out, [ 1, 2, 0, 0 ], 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array-like object)', function test( t ) { - var expected; - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = { - 'length': 4, - '0': 1, - '1': 2, - '2': NaN, - '3': 3 - }; - out = { - 'length': 4, - '0': 0, - '1': 0, - '2': 0, - '3': 0 - }; - - untilEach( arr, predicate, copy ); - - expected = { - 'length': 4, - '0': 1, - '1': 2, - '2': 0, - '3': 0 - }; - - t.deepEqual( out, expected, 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (typed array)', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = new Float64Array( [ 1.0, 2.0, NaN, 3.0 ] ); - out = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - untilEach( arr, predicate, copy ); - - t.strictEqual( out[ 0 ], 1.0, 'expected result' ); - t.strictEqual( out[ 1 ], 2.0, 'expected result' ); - t.strictEqual( out[ 2 ], 0.0, 'expected result' ); - t.strictEqual( out[ 3 ], 0.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx; - var arr; - - function predicate( value ) { - return ( value !== value ); - } - - function sum( value ) { - /* eslint-disable no-invalid-this */ - this.sum += value; - this.count += 1; - } - - ctx = { - 'sum': 0, - 'count': 0 - }; - arr = [ 1.0, 2.0, 3.0 ]; - - untilEach( arr, predicate, sum, ctx ); - - t.strictEqual( ctx.sum/ctx.count, 2.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function provides basic support for dynamic arrays', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index, collection ) { - out.push( value ); - if ( index === collection.length-1 && collection.length < 10 ) { - collection.push( index+2 ); - } - } - - arr = [ 1, 2, 3 ]; - out = []; - - untilEach( arr, predicate, copy ); - - t.deepEqual( arr, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.deepEqual( out, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.end(); -}); - -tape( 'the function does not skip empty elements', function test( t ) { - var expected; - var arr; - - function predicate( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - return false; - } - - function verify( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - } - - arr = [ 1, , , 4 ]; // eslint-disable-line no-sparse-arrays - expected = [ 1, void 0, void 0, 4 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); - -tape( 'the function invokes the predicate function and the function to apply with three arguments: value, index, collection', function test( t ) { - var indices; - var values; - var arr; - - function predicate( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - return false; - } - - function verify( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - } - - arr = [ 1, 2, 3, 4 ]; - values = [ 1, 2, 3, 4 ]; - indices = [ 0, 1, 2, 3 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); From e6cac668f3a4bb981292de34bf7ef6c48760c751 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Aug 2023 06:17:34 +0000 Subject: [PATCH 053/135] 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 846d968..0be8304 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,13 +56,13 @@ function untilEach( collection, predicate, fcn, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); + throw new TypeError( format( '0lxBO', collection ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '0lx2S', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0lx3Z', fcn ) ); } len = collection.length; i = 0; diff --git a/package.json b/package.json index 66f6f95..129e621 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-collection": "^0.0.8", "@stdlib/assert-is-function": "^0.0.8", - "@stdlib/string-format": "^0.0.3", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2", "@stdlib/types": "^0.0.14" }, "devDependencies": { From 5c4feaa0641061be815910e64cb396e2617ed532 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Aug 2023 14:34:17 +0000 Subject: [PATCH 054/135] Remove files --- index.d.ts | 142 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6324 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 bb940c1..0000000 --- a/index.d.ts +++ /dev/null @@ -1,142 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/object'; - -/** -* Checks whether an element in a collection passes a test. -* -* @returns boolean indicating whether an element in a collection passes a test -*/ -type NullaryPredicate = () => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @returns boolean indicating whether an element in a collection passes a test -*/ -type UnaryPredicate = ( value: T ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @returns boolean indicating whether an element in a collection passes a test -*/ -type BinaryPredicate = ( value: T, index: number ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type TernaryPredicate = ( value: T, index: number, collection: Collection ) => boolean; // tslint-disable-line max-line-length - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Predicate = NullaryPredicate | UnaryPredicate | BinaryPredicate | TernaryPredicate; // tslint-disable-line max-line-length - -/** -* Function invoked for each collection element until test condition is true. -*/ -type Nullary = () => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -*/ -type Unary = ( value: T ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -*/ -type Binary = ( value: T, index: number ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Ternary = ( value: T, index: number, collection: Collection ) => void; // tslint-disable-line max-line-length - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Until a test condition is true, invokes a function once for each element in a collection. -* -* ## Notes -* -* - When invoked, both the predicate function and the function to apply are provided three arguments: -* -* - `value`: collection value -* - `index`: collection index -* - `collection`: the input collection -* -* @param collection - input collection -* @param predicate - function which indicates whether to stop iterating over a collection -* @param fcn - function to invoke -* @param thisArg - execution context for the applied function -* @returns input collection -* -* @example -* function predicate( v, key, collection ) { -* return ( v !== v ); -* } -* -* function log( v, key, collection ) { -* console.log( '%s: %d', key, v ); -* } -* -* var arr = [ 1, 2, 3, 4, NaN, 5 ]; -* -* untilEach( arr, predicate, log ); -*/ -declare function untilEach( collection: Collection, predicate: Predicate, fcn: Callback, thisArg?: any ): Collection; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = untilEach; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 1f35a3f..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s,o,i,n){var l,d;if(!r(s))throw new TypeError(e("0lxBO",s));if(!t(o))throw new TypeError(e("0lx2S",o));if(!t(i))throw new TypeError(e("0lx3Z",i));for(l=s.length,d=0;d - - - - - - Rollup Visualizer - - - -
- - - - - From be67dc7194d9d7e5bfa892b3612d2196da975fc0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Aug 2023 14:35:20 +0000 Subject: [PATCH 055/135] 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 | 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 | 43 +- benchmark/benchmark.js | 89 - branches.md | 53 - docs/repl.txt | 47 - docs/types/test.ts | 89 - examples/index.js | 53 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 83 - package.json | 61 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 350 -- 37 files changed, 6203 insertions(+), 3980 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 88f1db8..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-08-01T04:08:58.936Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 038a13c..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/utils/until-each) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f023c60..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/utils/until-each) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 6610ebe..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: '35 11 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 334eb59..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@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 + + ```
@@ -282,7 +275,7 @@ untilEach( arr, predicate, log ); ## 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]. @@ -350,9 +343,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right +[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right/tree/esm -[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each +[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 16edfdb..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var untilEach = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var sum; - var i; - - function predicate( v ) { - return isnan( v ); - } - - function fcn( v ) { - sum += v; - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - untilEach( arr, predicate, fcn ); - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::loop', function benchmark( b ) { - var sum; - var arr; - var i; - var j; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - j = 0; - while ( j < arr.length ) { - if ( isnan( arr[ j ] ) ) { - break; - } - sum += arr[ j ]; - j += 1; - } - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 3a445ad..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/utils/until-each" -%% click B href "https://github.com/stdlib-js/utils-until-each/tree/main" -%% click C href "https://github.com/stdlib-js/utils-until-each/tree/production" -%% click D href "https://github.com/stdlib-js/utils-until-each/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-until-each/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-until-each/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/until-each -[production-url]: https://github.com/stdlib-js/utils-until-each/tree/production -[deno-url]: https://github.com/stdlib-js/utils-until-each/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-until-each/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-until-each/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 11ef9f4..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,47 +0,0 @@ - -{{alias}}( collection, predicate, fcn[, thisArg] ) - Until a test condition is true, invokes a function for each element in a - collection. - - When invoked, both the predicate function and the function to apply are - provided three arguments: - - - `value`: collection value - - `index`: collection index - - `collection`: the input collection - - Parameters - ---------- - collection: Array|TypedArray|Object - Input collection over which to iterate. If provided an object, the - object must be array-like (excluding strings and functions). - - predicate: Function - The predicate function which indicates whether to stop iterating over a - collection. - - fcn: Function - The function to invoke for each element in a collection. - - thisArg: any (optional) - Execution context for the applied function. - - Returns - ------- - out: Array|TypedArray|Object - Input collection. - - Examples - -------- - > function predicate( v ) { return v !== v; }; - > function logger( v, i ) { console.log( '%s: %d', i, v ); }; - > var arr = [ 1, 2, 3, 4, NaN, 5 ]; - > {{alias}}( arr, predicate, logger ) - 0: 1 - 1: 2 - 2: 3 - 3: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4833283..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,89 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 untilEach = require( './index' ); - -/** -* Test function. -* -* @param v - value -* @param index - index -*/ -function fcn( v: number, index: number ): void { - if ( v !== v ) { - throw new Error( 'beep' ); - } - if ( index !== index ) { - throw new Error( 'beep' ); - } -} - -/** -* Test function. -* -* @param v - value -* @returns result -*/ -function isnan( v: number ): boolean { - return ( v !== v ); -} - - -// TESTS // - -// The function returns the input collection... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, fcn ); // $ExpectType Collection - untilEach( [ -1, 1, 2 ], isnan, fcn, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - untilEach( 2, isnan, fcn ); // $ExpectError - untilEach( false, isnan, fcn ); // $ExpectError - untilEach( true, isnan, fcn ); // $ExpectError - untilEach( {}, isnan, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], 2, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], false, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], true, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], 'abc', fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], {}, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], [], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, 2 ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, false ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, true ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, 'abc' ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, {} ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - untilEach(); // $ExpectError - untilEach( [ 1, 2, 3 ] ); // $ExpectError - untilEach( [ 1, 2, 3 ], isnan ); // $ExpectError - untilEach( [ 1, 2, 3 ], isnan, fcn, {}, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index c41d90c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isEven = require( '@stdlib/assert-is-even' ).isPrimitive; -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var untilEach = require( './../lib' ); - -function predicate( value ) { - return ( value !== value ); -} - -function log( value, index, collection ) { - console.log( '%s: %d', index, value ); - if ( isEven( index ) ) { - collection.shift(); - } else { - collection.push( index+1 ); - } -} - -var arr; -var j; -var i; - -arr = new Array( 100 ); -j = floor( randu()*arr.length ); -for ( i = 0; i < arr.length; i++ ) { - if ( i === j ) { - arr[ i ] = NaN; - } else { - arr[ i ] = i; - } -} - -untilEach( arr, predicate, log ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index b8f0885..bb940c1 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/object'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..1f35a3f --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s,o,i,n){var l,d;if(!r(s))throw new TypeError(e("0lxBO",s));if(!t(o))throw new TypeError(e("0lx2S",o));if(!t(i))throw new TypeError(e("0lx3Z",i));for(l=s.length,d=0;d=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..4bcb9a1 --- /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 70a1888..0000000 --- a/test/test.js +++ /dev/null @@ -1,350 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var untilEach = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof untilEach, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {}, - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( value, noop, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a predicate function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a function to invoke', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], noop, value ); - }; - } -}); - -tape( 'if provided an empty collection, the function never invokes a provided function', function test( t ) { - var arr = []; - - function predicate() { - t.fail( 'should not be invoked' ); - } - - function foo() { - t.fail( 'should not be invoked' ); - } - - untilEach( arr, predicate, foo ); - - t.deepEqual( arr, [], 'expected result' ); - t.end(); -}); - -tape( 'the function returns the input collection', function test( t ) { - var arr; - var out; - - function predicate() { - t.pass( 'invoked predicated function' ); - return false; - } - - function foo() { - t.pass( 'invoked provided function' ); - } - - arr = [ 1, 2, 3 ]; - - out = untilEach( arr, predicate, foo ); - - t.strictEqual( out, arr, 'returns input collection' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array)', function test( t ) { - var arr; - var out; - - arr = [ 1, 2, NaN, 3 ]; - out = [ 0, 0, 0, 0 ]; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - untilEach( arr, predicate, copy ); - - t.deepEqual( out, [ 1, 2, 0, 0 ], 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array-like object)', function test( t ) { - var expected; - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = { - 'length': 4, - '0': 1, - '1': 2, - '2': NaN, - '3': 3 - }; - out = { - 'length': 4, - '0': 0, - '1': 0, - '2': 0, - '3': 0 - }; - - untilEach( arr, predicate, copy ); - - expected = { - 'length': 4, - '0': 1, - '1': 2, - '2': 0, - '3': 0 - }; - - t.deepEqual( out, expected, 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (typed array)', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = new Float64Array( [ 1.0, 2.0, NaN, 3.0 ] ); - out = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - untilEach( arr, predicate, copy ); - - t.strictEqual( out[ 0 ], 1.0, 'expected result' ); - t.strictEqual( out[ 1 ], 2.0, 'expected result' ); - t.strictEqual( out[ 2 ], 0.0, 'expected result' ); - t.strictEqual( out[ 3 ], 0.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx; - var arr; - - function predicate( value ) { - return ( value !== value ); - } - - function sum( value ) { - /* eslint-disable no-invalid-this */ - this.sum += value; - this.count += 1; - } - - ctx = { - 'sum': 0, - 'count': 0 - }; - arr = [ 1.0, 2.0, 3.0 ]; - - untilEach( arr, predicate, sum, ctx ); - - t.strictEqual( ctx.sum/ctx.count, 2.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function provides basic support for dynamic arrays', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index, collection ) { - out.push( value ); - if ( index === collection.length-1 && collection.length < 10 ) { - collection.push( index+2 ); - } - } - - arr = [ 1, 2, 3 ]; - out = []; - - untilEach( arr, predicate, copy ); - - t.deepEqual( arr, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.deepEqual( out, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.end(); -}); - -tape( 'the function does not skip empty elements', function test( t ) { - var expected; - var arr; - - function predicate( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - return false; - } - - function verify( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - } - - arr = [ 1, , , 4 ]; // eslint-disable-line no-sparse-arrays - expected = [ 1, void 0, void 0, 4 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); - -tape( 'the function invokes the predicate function and the function to apply with three arguments: value, index, collection', function test( t ) { - var indices; - var values; - var arr; - - function predicate( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - return false; - } - - function verify( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - } - - arr = [ 1, 2, 3, 4 ]; - values = [ 1, 2, 3, 4 ]; - indices = [ 0, 1, 2, 3 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); From 2fe6c384db496f0a96450a1770aa3ee7a4e76401 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 23 Sep 2023 15:50:05 +0000 Subject: [PATCH 056/135] 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 846d968..0cddcca 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,13 +56,13 @@ function untilEach( collection, predicate, fcn, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); + throw new TypeError( format( '1YDAh,O3', collection ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '1YD2H,G6', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '1YD3N,G4', fcn ) ); } len = collection.length; i = 0; diff --git a/package.json b/package.json index 6dd3ca0..f41cac5 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-collection": "^0.1.0", "@stdlib/assert-is-function": "^0.1.0", - "@stdlib/string-format": "^0.1.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.0", "@stdlib/types": "^0.1.0" }, "devDependencies": { From 4016f13dcc6aca0fa9f05a37cb2d32fd29b8c98b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 23 Sep 2023 17:15:29 +0000 Subject: [PATCH 057/135] Remove files --- index.d.ts | 142 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6324 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 bb940c1..0000000 --- a/index.d.ts +++ /dev/null @@ -1,142 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/object'; - -/** -* Checks whether an element in a collection passes a test. -* -* @returns boolean indicating whether an element in a collection passes a test -*/ -type NullaryPredicate = () => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @returns boolean indicating whether an element in a collection passes a test -*/ -type UnaryPredicate = ( value: T ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @returns boolean indicating whether an element in a collection passes a test -*/ -type BinaryPredicate = ( value: T, index: number ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type TernaryPredicate = ( value: T, index: number, collection: Collection ) => boolean; // tslint-disable-line max-line-length - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Predicate = NullaryPredicate | UnaryPredicate | BinaryPredicate | TernaryPredicate; // tslint-disable-line max-line-length - -/** -* Function invoked for each collection element until test condition is true. -*/ -type Nullary = () => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -*/ -type Unary = ( value: T ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -*/ -type Binary = ( value: T, index: number ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Ternary = ( value: T, index: number, collection: Collection ) => void; // tslint-disable-line max-line-length - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Until a test condition is true, invokes a function once for each element in a collection. -* -* ## Notes -* -* - When invoked, both the predicate function and the function to apply are provided three arguments: -* -* - `value`: collection value -* - `index`: collection index -* - `collection`: the input collection -* -* @param collection - input collection -* @param predicate - function which indicates whether to stop iterating over a collection -* @param fcn - function to invoke -* @param thisArg - execution context for the applied function -* @returns input collection -* -* @example -* function predicate( v, key, collection ) { -* return ( v !== v ); -* } -* -* function log( v, key, collection ) { -* console.log( '%s: %d', key, v ); -* } -* -* var arr = [ 1, 2, 3, 4, NaN, 5 ]; -* -* untilEach( arr, predicate, log ); -*/ -declare function untilEach( collection: Collection, predicate: Predicate, fcn: Callback, thisArg?: any ): Collection; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = untilEach; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 1f35a3f..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s,o,i,n){var l,d;if(!r(s))throw new TypeError(e("0lxBO",s));if(!t(o))throw new TypeError(e("0lx2S",o));if(!t(i))throw new TypeError(e("0lx3Z",i));for(l=s.length,d=0;d - - - - - - Rollup Visualizer - - - -
- - - - - From dd18cd610e28e50547efe881c997b7f81052b4f2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 23 Sep 2023 17:17:38 +0000 Subject: [PATCH 058/135] 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 | 43 +- benchmark/benchmark.js | 89 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 47 - docs/types/test.ts | 89 - examples/index.js | 53 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 83 - package.json | 61 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 350 -- 40 files changed, 6203 insertions(+), 4014 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 038a13c..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/utils/until-each) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 f023c60..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/utils/until-each) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 6610ebe..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: '35 11 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 91f2b93..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,783 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -293,7 +286,7 @@ untilEach( arr, predicate, log ); ## 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]. @@ -361,9 +354,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right +[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right/tree/esm -[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each +[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 16edfdb..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var untilEach = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var sum; - var i; - - function predicate( v ) { - return isnan( v ); - } - - function fcn( v ) { - sum += v; - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - untilEach( arr, predicate, fcn ); - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::loop', function benchmark( b ) { - var sum; - var arr; - var i; - var j; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - j = 0; - while ( j < arr.length ) { - if ( isnan( arr[ j ] ) ) { - break; - } - sum += arr[ j ]; - j += 1; - } - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 3a445ad..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/utils/until-each" -%% click B href "https://github.com/stdlib-js/utils-until-each/tree/main" -%% click C href "https://github.com/stdlib-js/utils-until-each/tree/production" -%% click D href "https://github.com/stdlib-js/utils-until-each/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-until-each/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-until-each/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/until-each -[production-url]: https://github.com/stdlib-js/utils-until-each/tree/production -[deno-url]: https://github.com/stdlib-js/utils-until-each/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-until-each/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-until-each/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 4378886..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import untilEach from '../docs/types/index'; -export = untilEach; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 52eaf73..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var g=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var m=g(function(E,s){ -var h=require('@stdlib/assert-is-collection/dist'),n=require('@stdlib/assert-is-function/dist'),i=require('@stdlib/error-tools-fmtprodmsg/dist');function w(r,e,a,v){var t,u;if(!h(r))throw new TypeError(i('1YDAh',r));if(!n(e))throw new TypeError(i('1YD2H',e));if(!n(a))throw new TypeError(i('1YD3N',a));for(t=r.length,u=0;u function predicate( v ) { return v !== v; }; - > function logger( v, i ) { console.log( '%s: %d', i, v ); }; - > var arr = [ 1, 2, 3, 4, NaN, 5 ]; - > {{alias}}( arr, predicate, logger ) - 0: 1 - 1: 2 - 2: 3 - 3: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4833283..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,89 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 untilEach = require( './index' ); - -/** -* Test function. -* -* @param v - value -* @param index - index -*/ -function fcn( v: number, index: number ): void { - if ( v !== v ) { - throw new Error( 'beep' ); - } - if ( index !== index ) { - throw new Error( 'beep' ); - } -} - -/** -* Test function. -* -* @param v - value -* @returns result -*/ -function isnan( v: number ): boolean { - return ( v !== v ); -} - - -// TESTS // - -// The function returns the input collection... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, fcn ); // $ExpectType Collection - untilEach( [ -1, 1, 2 ], isnan, fcn, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - untilEach( 2, isnan, fcn ); // $ExpectError - untilEach( false, isnan, fcn ); // $ExpectError - untilEach( true, isnan, fcn ); // $ExpectError - untilEach( {}, isnan, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], 2, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], false, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], true, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], 'abc', fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], {}, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], [], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, 2 ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, false ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, true ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, 'abc' ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, {} ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - untilEach(); // $ExpectError - untilEach( [ 1, 2, 3 ] ); // $ExpectError - untilEach( [ 1, 2, 3 ], isnan ); // $ExpectError - untilEach( [ 1, 2, 3 ], isnan, fcn, {}, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index c41d90c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isEven = require( '@stdlib/assert-is-even' ).isPrimitive; -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var untilEach = require( './../lib' ); - -function predicate( value ) { - return ( value !== value ); -} - -function log( value, index, collection ) { - console.log( '%s: %d', index, value ); - if ( isEven( index ) ) { - collection.shift(); - } else { - collection.push( index+1 ); - } -} - -var arr; -var j; -var i; - -arr = new Array( 100 ); -j = floor( randu()*arr.length ); -for ( i = 0; i < arr.length; i++ ) { - if ( i === j ) { - arr[ i ] = NaN; - } else { - arr[ i ] = i; - } -} - -untilEach( arr, predicate, log ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 19fe169..355b4df 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..baa0d25 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.0-esm/index.mjs";function s(s,o,i,n){var d,l;if(!r(s))throw new TypeError(e("1YDAh,O3",s));if(!t(o))throw new TypeError(e("1YD2H,G6",o));if(!t(i))throw new TypeError(e("1YD3N,G4",i));for(d=s.length,l=0;l=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..1e3fb4c --- /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 70a1888..0000000 --- a/test/test.js +++ /dev/null @@ -1,350 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var untilEach = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof untilEach, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {}, - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( value, noop, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a predicate function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a function to invoke', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], noop, value ); - }; - } -}); - -tape( 'if provided an empty collection, the function never invokes a provided function', function test( t ) { - var arr = []; - - function predicate() { - t.fail( 'should not be invoked' ); - } - - function foo() { - t.fail( 'should not be invoked' ); - } - - untilEach( arr, predicate, foo ); - - t.deepEqual( arr, [], 'expected result' ); - t.end(); -}); - -tape( 'the function returns the input collection', function test( t ) { - var arr; - var out; - - function predicate() { - t.pass( 'invoked predicated function' ); - return false; - } - - function foo() { - t.pass( 'invoked provided function' ); - } - - arr = [ 1, 2, 3 ]; - - out = untilEach( arr, predicate, foo ); - - t.strictEqual( out, arr, 'returns input collection' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array)', function test( t ) { - var arr; - var out; - - arr = [ 1, 2, NaN, 3 ]; - out = [ 0, 0, 0, 0 ]; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - untilEach( arr, predicate, copy ); - - t.deepEqual( out, [ 1, 2, 0, 0 ], 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array-like object)', function test( t ) { - var expected; - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = { - 'length': 4, - '0': 1, - '1': 2, - '2': NaN, - '3': 3 - }; - out = { - 'length': 4, - '0': 0, - '1': 0, - '2': 0, - '3': 0 - }; - - untilEach( arr, predicate, copy ); - - expected = { - 'length': 4, - '0': 1, - '1': 2, - '2': 0, - '3': 0 - }; - - t.deepEqual( out, expected, 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (typed array)', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = new Float64Array( [ 1.0, 2.0, NaN, 3.0 ] ); - out = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - untilEach( arr, predicate, copy ); - - t.strictEqual( out[ 0 ], 1.0, 'expected result' ); - t.strictEqual( out[ 1 ], 2.0, 'expected result' ); - t.strictEqual( out[ 2 ], 0.0, 'expected result' ); - t.strictEqual( out[ 3 ], 0.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx; - var arr; - - function predicate( value ) { - return ( value !== value ); - } - - function sum( value ) { - /* eslint-disable no-invalid-this */ - this.sum += value; - this.count += 1; - } - - ctx = { - 'sum': 0, - 'count': 0 - }; - arr = [ 1.0, 2.0, 3.0 ]; - - untilEach( arr, predicate, sum, ctx ); - - t.strictEqual( ctx.sum/ctx.count, 2.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function provides basic support for dynamic arrays', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index, collection ) { - out.push( value ); - if ( index === collection.length-1 && collection.length < 10 ) { - collection.push( index+2 ); - } - } - - arr = [ 1, 2, 3 ]; - out = []; - - untilEach( arr, predicate, copy ); - - t.deepEqual( arr, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.deepEqual( out, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.end(); -}); - -tape( 'the function does not skip empty elements', function test( t ) { - var expected; - var arr; - - function predicate( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - return false; - } - - function verify( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - } - - arr = [ 1, , , 4 ]; // eslint-disable-line no-sparse-arrays - expected = [ 1, void 0, void 0, 4 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); - -tape( 'the function invokes the predicate function and the function to apply with three arguments: value, index, collection', function test( t ) { - var indices; - var values; - var arr; - - function predicate( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - return false; - } - - function verify( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - } - - arr = [ 1, 2, 3, 4 ]; - values = [ 1, 2, 3, 4 ]; - indices = [ 0, 1, 2, 3 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); From 2bc510f445b5c362b77fb8a36103ce4b8b96ea24 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 23 Sep 2023 17:52:17 +0000 Subject: [PATCH 059/135] 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 7f700d2..1e50cdf 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import untilEach from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-until-each@esm/index.mjs'; +import untilEach from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-until-each@v0.1.0-esm/index.mjs'; ``` #### untilEach( collection, predicate, fcn\[, thisArg ] ) @@ -214,7 +214,7 @@ var mean = context.sum / context.count; var isEven = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-even' ).isPrimitive; import randu from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-randu@esm/index.mjs'; import floor from 'https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@esm/index.mjs'; -import untilEach from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-until-each@esm/index.mjs'; +import untilEach from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-until-each@v0.1.0-esm/index.mjs'; function predicate( value ) { return ( value !== value ); From b325cfecfb1ff35465fca64a2f2f09d3a2b6b485 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 23 Sep 2023 17:52:18 +0000 Subject: [PATCH 060/135] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1e50cdf..0582b08 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ limitations under the License. ## Usage +```javascript +import untilEach from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-until-each@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/utils-until-each/tags). For example, + ```javascript import untilEach from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-until-each@v0.1.0-esm/index.mjs'; ``` @@ -214,7 +219,7 @@ var mean = context.sum / context.count; var isEven = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-even' ).isPrimitive; import randu from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-randu@esm/index.mjs'; import floor from 'https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@esm/index.mjs'; -import untilEach from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-until-each@v0.1.0-esm/index.mjs'; +import untilEach from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-until-each@esm/index.mjs'; function predicate( value ) { return ( value !== value ); From dc758b216b73e3284a78f405687447079946705c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Oct 2023 07:47:57 +0000 Subject: [PATCH 061/135] 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 846d968..0cddcca 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,13 +56,13 @@ function untilEach( collection, predicate, fcn, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); + throw new TypeError( format( '1YDAh,O3', collection ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '1YD2H,G6', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '1YD3N,G4', fcn ) ); } len = collection.length; i = 0; diff --git a/package.json b/package.json index c0d6c87..c286824 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-collection": "^0.1.0", "@stdlib/assert-is-function": "^0.1.0", - "@stdlib/string-format": "^0.1.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.0", "@stdlib/types": "^0.1.0" }, "devDependencies": { From bd1a5c9102467e8a6c088fa08b105e9a20db6c84 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 2 Oct 2023 12:39:43 +0000 Subject: [PATCH 062/135] Remove files --- index.d.ts | 142 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6324 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 355b4df..0000000 --- a/index.d.ts +++ /dev/null @@ -1,142 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Checks whether an element in a collection passes a test. -* -* @returns boolean indicating whether an element in a collection passes a test -*/ -type NullaryPredicate = () => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @returns boolean indicating whether an element in a collection passes a test -*/ -type UnaryPredicate = ( value: T ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @returns boolean indicating whether an element in a collection passes a test -*/ -type BinaryPredicate = ( value: T, index: number ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type TernaryPredicate = ( value: T, index: number, collection: Collection ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Predicate = NullaryPredicate | UnaryPredicate | BinaryPredicate | TernaryPredicate; - -/** -* Function invoked for each collection element until test condition is true. -*/ -type Nullary = ( this: U ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -*/ -type Unary = ( this: U, value: T ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -*/ -type Binary = ( this: U, value: T, index: number ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Ternary = ( this: U, value: T, index: number, collection: Collection ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Until a test condition is true, invokes a function once for each element in a collection. -* -* ## Notes -* -* - When invoked, both the predicate function and the function to apply are provided three arguments: -* -* - `value`: collection value -* - `index`: collection index -* - `collection`: the input collection -* -* @param collection - input collection -* @param predicate - function which indicates whether to stop iterating over a collection -* @param fcn - function to invoke -* @param thisArg - execution context for the applied function -* @returns input collection -* -* @example -* function predicate( v, key, collection ) { -* return ( v !== v ); -* } -* -* function log( v, key, collection ) { -* console.log( '%s: %d', key, v ); -* } -* -* var arr = [ 1, 2, 3, 4, NaN, 5 ]; -* -* untilEach( arr, predicate, log ); -*/ -declare function untilEach( collection: Collection, predicate: Predicate, fcn: Callback, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = untilEach; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index baa0d25..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.0-esm/index.mjs";function s(s,o,i,n){var d,l;if(!r(s))throw new TypeError(e("1YDAh,O3",s));if(!t(o))throw new TypeError(e("1YD2H,G6",o));if(!t(i))throw new TypeError(e("1YD3N,G4",i));for(d=s.length,l=0;l - - - - - - Rollup Visualizer - - - -
- - - - - From 7450818f5b769f14d8b7e2a2898d9f7e76197e75 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 2 Oct 2023 12:42:39 +0000 Subject: [PATCH 063/135] 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 | 43 +- benchmark/benchmark.js | 89 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 47 - docs/types/test.ts | 89 - examples/index.js | 53 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 83 - package.json | 61 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 350 -- test/test.js | 350 -- 42 files changed, 6203 insertions(+), 4423 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 83b61d3..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-10-01T02:46:20.415Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 038a13c..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/utils/until-each) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 4eecda2..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/utils/until-each) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 9d21033..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: '35 11 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -293,7 +286,7 @@ untilEach( arr, predicate, log ); ## 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]. @@ -361,9 +354,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right +[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right/tree/esm -[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each +[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 16edfdb..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var untilEach = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var sum; - var i; - - function predicate( v ) { - return isnan( v ); - } - - function fcn( v ) { - sum += v; - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - untilEach( arr, predicate, fcn ); - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::loop', function benchmark( b ) { - var sum; - var arr; - var i; - var j; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - j = 0; - while ( j < arr.length ) { - if ( isnan( arr[ j ] ) ) { - break; - } - sum += arr[ j ]; - j += 1; - } - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 3a445ad..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/utils/until-each" -%% click B href "https://github.com/stdlib-js/utils-until-each/tree/main" -%% click C href "https://github.com/stdlib-js/utils-until-each/tree/production" -%% click D href "https://github.com/stdlib-js/utils-until-each/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-until-each/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-until-each/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/until-each -[production-url]: https://github.com/stdlib-js/utils-until-each/tree/production -[deno-url]: https://github.com/stdlib-js/utils-until-each/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-until-each/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-until-each/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 4378886..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import untilEach from '../docs/types/index'; -export = untilEach; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 52eaf73..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var g=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var m=g(function(E,s){ -var h=require('@stdlib/assert-is-collection/dist'),n=require('@stdlib/assert-is-function/dist'),i=require('@stdlib/error-tools-fmtprodmsg/dist');function w(r,e,a,v){var t,u;if(!h(r))throw new TypeError(i('1YDAh',r));if(!n(e))throw new TypeError(i('1YD2H',e));if(!n(a))throw new TypeError(i('1YD3N',a));for(t=r.length,u=0;u function predicate( v ) { return v !== v; }; - > function logger( v, i ) { console.log( '%s: %d', i, v ); }; - > var arr = [ 1, 2, 3, 4, NaN, 5 ]; - > {{alias}}( arr, predicate, logger ) - 0: 1 - 1: 2 - 2: 3 - 3: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4833283..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,89 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 untilEach = require( './index' ); - -/** -* Test function. -* -* @param v - value -* @param index - index -*/ -function fcn( v: number, index: number ): void { - if ( v !== v ) { - throw new Error( 'beep' ); - } - if ( index !== index ) { - throw new Error( 'beep' ); - } -} - -/** -* Test function. -* -* @param v - value -* @returns result -*/ -function isnan( v: number ): boolean { - return ( v !== v ); -} - - -// TESTS // - -// The function returns the input collection... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, fcn ); // $ExpectType Collection - untilEach( [ -1, 1, 2 ], isnan, fcn, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - untilEach( 2, isnan, fcn ); // $ExpectError - untilEach( false, isnan, fcn ); // $ExpectError - untilEach( true, isnan, fcn ); // $ExpectError - untilEach( {}, isnan, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], 2, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], false, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], true, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], 'abc', fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], {}, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], [], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, 2 ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, false ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, true ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, 'abc' ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, {} ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - untilEach(); // $ExpectError - untilEach( [ 1, 2, 3 ] ); // $ExpectError - untilEach( [ 1, 2, 3 ], isnan ); // $ExpectError - untilEach( [ 1, 2, 3 ], isnan, fcn, {}, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index c41d90c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isEven = require( '@stdlib/assert-is-even' ).isPrimitive; -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var untilEach = require( './../lib' ); - -function predicate( value ) { - return ( value !== value ); -} - -function log( value, index, collection ) { - console.log( '%s: %d', index, value ); - if ( isEven( index ) ) { - collection.shift(); - } else { - collection.push( index+1 ); - } -} - -var arr; -var j; -var i; - -arr = new Array( 100 ); -j = floor( randu()*arr.length ); -for ( i = 0; i < arr.length; i++ ) { - if ( i === j ) { - arr[ i ] = NaN; - } else { - arr[ i ] = i; - } -} - -untilEach( arr, predicate, log ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 19fe169..355b4df 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..db5ebc7 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.0-esm/index.mjs";function s(s,o,i,n){var d,l;if(!r(s))throw new TypeError(e("1YDAh,O3",s));if(!t(o))throw new TypeError(e("1YD2H,G6",o));if(!t(i))throw new TypeError(e("1YD3N,G4",i));for(d=s.length,l=0;l=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..d9267a4 --- /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 f28b1cb..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,350 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var untilEach = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof untilEach, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {}, - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( value, noop, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a predicate function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a function to invoke', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], noop, value ); - }; - } -}); - -tape( 'if provided an empty collection, the function never invokes a provided function', function test( t ) { - var arr = []; - - function predicate() { - t.fail( 'should not be invoked' ); - } - - function foo() { - t.fail( 'should not be invoked' ); - } - - untilEach( arr, predicate, foo ); - - t.deepEqual( arr, [], 'expected result' ); - t.end(); -}); - -tape( 'the function returns the input collection', function test( t ) { - var arr; - var out; - - function predicate() { - t.pass( 'invoked predicated function' ); - return false; - } - - function foo() { - t.pass( 'invoked provided function' ); - } - - arr = [ 1, 2, 3 ]; - - out = untilEach( arr, predicate, foo ); - - t.strictEqual( out, arr, 'returns input collection' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array)', function test( t ) { - var arr; - var out; - - arr = [ 1, 2, NaN, 3 ]; - out = [ 0, 0, 0, 0 ]; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - untilEach( arr, predicate, copy ); - - t.deepEqual( out, [ 1, 2, 0, 0 ], 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array-like object)', function test( t ) { - var expected; - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = { - 'length': 4, - '0': 1, - '1': 2, - '2': NaN, - '3': 3 - }; - out = { - 'length': 4, - '0': 0, - '1': 0, - '2': 0, - '3': 0 - }; - - untilEach( arr, predicate, copy ); - - expected = { - 'length': 4, - '0': 1, - '1': 2, - '2': 0, - '3': 0 - }; - - t.deepEqual( out, expected, 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (typed array)', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = new Float64Array( [ 1.0, 2.0, NaN, 3.0 ] ); - out = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - untilEach( arr, predicate, copy ); - - t.strictEqual( out[ 0 ], 1.0, 'expected result' ); - t.strictEqual( out[ 1 ], 2.0, 'expected result' ); - t.strictEqual( out[ 2 ], 0.0, 'expected result' ); - t.strictEqual( out[ 3 ], 0.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx; - var arr; - - function predicate( value ) { - return ( value !== value ); - } - - function sum( value ) { - /* eslint-disable no-invalid-this */ - this.sum += value; - this.count += 1; - } - - ctx = { - 'sum': 0, - 'count': 0 - }; - arr = [ 1.0, 2.0, 3.0 ]; - - untilEach( arr, predicate, sum, ctx ); - - t.strictEqual( ctx.sum/ctx.count, 2.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function provides basic support for dynamic arrays', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index, collection ) { - out.push( value ); - if ( index === collection.length-1 && collection.length < 10 ) { - collection.push( index+2 ); - } - } - - arr = [ 1, 2, 3 ]; - out = []; - - untilEach( arr, predicate, copy ); - - t.deepEqual( arr, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.deepEqual( out, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.end(); -}); - -tape( 'the function does not skip empty elements', function test( t ) { - var expected; - var arr; - - function predicate( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - return false; - } - - function verify( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - } - - arr = [ 1, , , 4 ]; // eslint-disable-line no-sparse-arrays - expected = [ 1, void 0, void 0, 4 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); - -tape( 'the function invokes the predicate function and the function to apply with three arguments: value, index, collection', function test( t ) { - var indices; - var values; - var arr; - - function predicate( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - return false; - } - - function verify( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - } - - arr = [ 1, 2, 3, 4 ]; - values = [ 1, 2, 3, 4 ]; - indices = [ 0, 1, 2, 3 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 70a1888..0000000 --- a/test/test.js +++ /dev/null @@ -1,350 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var untilEach = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof untilEach, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {}, - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( value, noop, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a predicate function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a function to invoke', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], noop, value ); - }; - } -}); - -tape( 'if provided an empty collection, the function never invokes a provided function', function test( t ) { - var arr = []; - - function predicate() { - t.fail( 'should not be invoked' ); - } - - function foo() { - t.fail( 'should not be invoked' ); - } - - untilEach( arr, predicate, foo ); - - t.deepEqual( arr, [], 'expected result' ); - t.end(); -}); - -tape( 'the function returns the input collection', function test( t ) { - var arr; - var out; - - function predicate() { - t.pass( 'invoked predicated function' ); - return false; - } - - function foo() { - t.pass( 'invoked provided function' ); - } - - arr = [ 1, 2, 3 ]; - - out = untilEach( arr, predicate, foo ); - - t.strictEqual( out, arr, 'returns input collection' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array)', function test( t ) { - var arr; - var out; - - arr = [ 1, 2, NaN, 3 ]; - out = [ 0, 0, 0, 0 ]; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - untilEach( arr, predicate, copy ); - - t.deepEqual( out, [ 1, 2, 0, 0 ], 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array-like object)', function test( t ) { - var expected; - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = { - 'length': 4, - '0': 1, - '1': 2, - '2': NaN, - '3': 3 - }; - out = { - 'length': 4, - '0': 0, - '1': 0, - '2': 0, - '3': 0 - }; - - untilEach( arr, predicate, copy ); - - expected = { - 'length': 4, - '0': 1, - '1': 2, - '2': 0, - '3': 0 - }; - - t.deepEqual( out, expected, 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (typed array)', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = new Float64Array( [ 1.0, 2.0, NaN, 3.0 ] ); - out = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - untilEach( arr, predicate, copy ); - - t.strictEqual( out[ 0 ], 1.0, 'expected result' ); - t.strictEqual( out[ 1 ], 2.0, 'expected result' ); - t.strictEqual( out[ 2 ], 0.0, 'expected result' ); - t.strictEqual( out[ 3 ], 0.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx; - var arr; - - function predicate( value ) { - return ( value !== value ); - } - - function sum( value ) { - /* eslint-disable no-invalid-this */ - this.sum += value; - this.count += 1; - } - - ctx = { - 'sum': 0, - 'count': 0 - }; - arr = [ 1.0, 2.0, 3.0 ]; - - untilEach( arr, predicate, sum, ctx ); - - t.strictEqual( ctx.sum/ctx.count, 2.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function provides basic support for dynamic arrays', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index, collection ) { - out.push( value ); - if ( index === collection.length-1 && collection.length < 10 ) { - collection.push( index+2 ); - } - } - - arr = [ 1, 2, 3 ]; - out = []; - - untilEach( arr, predicate, copy ); - - t.deepEqual( arr, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.deepEqual( out, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.end(); -}); - -tape( 'the function does not skip empty elements', function test( t ) { - var expected; - var arr; - - function predicate( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - return false; - } - - function verify( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - } - - arr = [ 1, , , 4 ]; // eslint-disable-line no-sparse-arrays - expected = [ 1, void 0, void 0, 4 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); - -tape( 'the function invokes the predicate function and the function to apply with three arguments: value, index, collection', function test( t ) { - var indices; - var values; - var arr; - - function predicate( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - return false; - } - - function verify( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - } - - arr = [ 1, 2, 3, 4 ]; - values = [ 1, 2, 3, 4 ]; - indices = [ 0, 1, 2, 3 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); From 7539536e651cc4b8342b1710a0f2599a6dac28d7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 5 Oct 2023 10:59:54 +0000 Subject: [PATCH 064/135] 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 846d968..0cddcca 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,13 +56,13 @@ function untilEach( collection, predicate, fcn, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); + throw new TypeError( format( '1YDAh,O3', collection ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '1YD2H,G6', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '1YD3N,G4', fcn ) ); } len = collection.length; i = 0; diff --git a/package.json b/package.json index 11f4ab2..d72448e 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-collection": "^0.1.0", "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.1.0" }, "devDependencies": { From 00dfc5bf88ceee8574bf5838e6c93e089d7d5d6e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 6 Oct 2023 14:16:17 +0000 Subject: [PATCH 065/135] Remove files --- index.d.ts | 142 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6324 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 355b4df..0000000 --- a/index.d.ts +++ /dev/null @@ -1,142 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Checks whether an element in a collection passes a test. -* -* @returns boolean indicating whether an element in a collection passes a test -*/ -type NullaryPredicate = () => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @returns boolean indicating whether an element in a collection passes a test -*/ -type UnaryPredicate = ( value: T ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @returns boolean indicating whether an element in a collection passes a test -*/ -type BinaryPredicate = ( value: T, index: number ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type TernaryPredicate = ( value: T, index: number, collection: Collection ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Predicate = NullaryPredicate | UnaryPredicate | BinaryPredicate | TernaryPredicate; - -/** -* Function invoked for each collection element until test condition is true. -*/ -type Nullary = ( this: U ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -*/ -type Unary = ( this: U, value: T ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -*/ -type Binary = ( this: U, value: T, index: number ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Ternary = ( this: U, value: T, index: number, collection: Collection ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Until a test condition is true, invokes a function once for each element in a collection. -* -* ## Notes -* -* - When invoked, both the predicate function and the function to apply are provided three arguments: -* -* - `value`: collection value -* - `index`: collection index -* - `collection`: the input collection -* -* @param collection - input collection -* @param predicate - function which indicates whether to stop iterating over a collection -* @param fcn - function to invoke -* @param thisArg - execution context for the applied function -* @returns input collection -* -* @example -* function predicate( v, key, collection ) { -* return ( v !== v ); -* } -* -* function log( v, key, collection ) { -* console.log( '%s: %d', key, v ); -* } -* -* var arr = [ 1, 2, 3, 4, NaN, 5 ]; -* -* untilEach( arr, predicate, log ); -*/ -declare function untilEach( collection: Collection, predicate: Predicate, fcn: Callback, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = untilEach; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index db5ebc7..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.0-esm/index.mjs";function s(s,o,i,n){var d,l;if(!r(s))throw new TypeError(e("1YDAh,O3",s));if(!t(o))throw new TypeError(e("1YD2H,G6",o));if(!t(i))throw new TypeError(e("1YD3N,G4",i));for(d=s.length,l=0;l - - - - - - Rollup Visualizer - - - -
- - - - - From c6caaaebd68c8627c10e94210a2fe5af9e6d745e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 6 Oct 2023 14:19:10 +0000 Subject: [PATCH 066/135] 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 | 43 +- benchmark/benchmark.js | 89 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 47 - docs/types/test.ts | 89 - examples/index.js | 53 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 83 - package.json | 61 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 350 -- test/test.js | 350 -- 41 files changed, 6203 insertions(+), 4422 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 038a13c..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/utils/until-each) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 4eecda2..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/utils/until-each) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 9d21033..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: '35 11 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -293,7 +286,7 @@ untilEach( arr, predicate, log ); ## 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]. @@ -361,9 +354,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right +[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right/tree/esm -[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each +[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 16edfdb..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var untilEach = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var sum; - var i; - - function predicate( v ) { - return isnan( v ); - } - - function fcn( v ) { - sum += v; - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - untilEach( arr, predicate, fcn ); - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::loop', function benchmark( b ) { - var sum; - var arr; - var i; - var j; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - j = 0; - while ( j < arr.length ) { - if ( isnan( arr[ j ] ) ) { - break; - } - sum += arr[ j ]; - j += 1; - } - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 3a445ad..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/utils/until-each" -%% click B href "https://github.com/stdlib-js/utils-until-each/tree/main" -%% click C href "https://github.com/stdlib-js/utils-until-each/tree/production" -%% click D href "https://github.com/stdlib-js/utils-until-each/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-until-each/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-until-each/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/until-each -[production-url]: https://github.com/stdlib-js/utils-until-each/tree/production -[deno-url]: https://github.com/stdlib-js/utils-until-each/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-until-each/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-until-each/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 4378886..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import untilEach from '../docs/types/index'; -export = untilEach; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 52eaf73..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var g=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var m=g(function(E,s){ -var h=require('@stdlib/assert-is-collection/dist'),n=require('@stdlib/assert-is-function/dist'),i=require('@stdlib/error-tools-fmtprodmsg/dist');function w(r,e,a,v){var t,u;if(!h(r))throw new TypeError(i('1YDAh',r));if(!n(e))throw new TypeError(i('1YD2H',e));if(!n(a))throw new TypeError(i('1YD3N',a));for(t=r.length,u=0;u function predicate( v ) { return v !== v; }; - > function logger( v, i ) { console.log( '%s: %d', i, v ); }; - > var arr = [ 1, 2, 3, 4, NaN, 5 ]; - > {{alias}}( arr, predicate, logger ) - 0: 1 - 1: 2 - 2: 3 - 3: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4833283..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,89 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 untilEach = require( './index' ); - -/** -* Test function. -* -* @param v - value -* @param index - index -*/ -function fcn( v: number, index: number ): void { - if ( v !== v ) { - throw new Error( 'beep' ); - } - if ( index !== index ) { - throw new Error( 'beep' ); - } -} - -/** -* Test function. -* -* @param v - value -* @returns result -*/ -function isnan( v: number ): boolean { - return ( v !== v ); -} - - -// TESTS // - -// The function returns the input collection... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, fcn ); // $ExpectType Collection - untilEach( [ -1, 1, 2 ], isnan, fcn, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - untilEach( 2, isnan, fcn ); // $ExpectError - untilEach( false, isnan, fcn ); // $ExpectError - untilEach( true, isnan, fcn ); // $ExpectError - untilEach( {}, isnan, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], 2, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], false, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], true, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], 'abc', fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], {}, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], [], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, 2 ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, false ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, true ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, 'abc' ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, {} ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - untilEach(); // $ExpectError - untilEach( [ 1, 2, 3 ] ); // $ExpectError - untilEach( [ 1, 2, 3 ], isnan ); // $ExpectError - untilEach( [ 1, 2, 3 ], isnan, fcn, {}, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index c41d90c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isEven = require( '@stdlib/assert-is-even' ).isPrimitive; -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var untilEach = require( './../lib' ); - -function predicate( value ) { - return ( value !== value ); -} - -function log( value, index, collection ) { - console.log( '%s: %d', index, value ); - if ( isEven( index ) ) { - collection.shift(); - } else { - collection.push( index+1 ); - } -} - -var arr; -var j; -var i; - -arr = new Array( 100 ); -j = floor( randu()*arr.length ); -for ( i = 0; i < arr.length; i++ ) { - if ( i === j ) { - arr[ i ] = NaN; - } else { - arr[ i ] = i; - } -} - -untilEach( arr, predicate, log ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 19fe169..355b4df 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..ea85daa --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";function s(s,o,i,n){var d,l;if(!r(s))throw new TypeError(e("1YDAh,O3",s));if(!t(o))throw new TypeError(e("1YD2H,G6",o));if(!t(i))throw new TypeError(e("1YD3N,G4",i));for(d=s.length,l=0;l=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b87238b --- /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 f28b1cb..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,350 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var untilEach = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof untilEach, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {}, - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( value, noop, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a predicate function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a function to invoke', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], noop, value ); - }; - } -}); - -tape( 'if provided an empty collection, the function never invokes a provided function', function test( t ) { - var arr = []; - - function predicate() { - t.fail( 'should not be invoked' ); - } - - function foo() { - t.fail( 'should not be invoked' ); - } - - untilEach( arr, predicate, foo ); - - t.deepEqual( arr, [], 'expected result' ); - t.end(); -}); - -tape( 'the function returns the input collection', function test( t ) { - var arr; - var out; - - function predicate() { - t.pass( 'invoked predicated function' ); - return false; - } - - function foo() { - t.pass( 'invoked provided function' ); - } - - arr = [ 1, 2, 3 ]; - - out = untilEach( arr, predicate, foo ); - - t.strictEqual( out, arr, 'returns input collection' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array)', function test( t ) { - var arr; - var out; - - arr = [ 1, 2, NaN, 3 ]; - out = [ 0, 0, 0, 0 ]; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - untilEach( arr, predicate, copy ); - - t.deepEqual( out, [ 1, 2, 0, 0 ], 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array-like object)', function test( t ) { - var expected; - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = { - 'length': 4, - '0': 1, - '1': 2, - '2': NaN, - '3': 3 - }; - out = { - 'length': 4, - '0': 0, - '1': 0, - '2': 0, - '3': 0 - }; - - untilEach( arr, predicate, copy ); - - expected = { - 'length': 4, - '0': 1, - '1': 2, - '2': 0, - '3': 0 - }; - - t.deepEqual( out, expected, 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (typed array)', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = new Float64Array( [ 1.0, 2.0, NaN, 3.0 ] ); - out = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - untilEach( arr, predicate, copy ); - - t.strictEqual( out[ 0 ], 1.0, 'expected result' ); - t.strictEqual( out[ 1 ], 2.0, 'expected result' ); - t.strictEqual( out[ 2 ], 0.0, 'expected result' ); - t.strictEqual( out[ 3 ], 0.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx; - var arr; - - function predicate( value ) { - return ( value !== value ); - } - - function sum( value ) { - /* eslint-disable no-invalid-this */ - this.sum += value; - this.count += 1; - } - - ctx = { - 'sum': 0, - 'count': 0 - }; - arr = [ 1.0, 2.0, 3.0 ]; - - untilEach( arr, predicate, sum, ctx ); - - t.strictEqual( ctx.sum/ctx.count, 2.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function provides basic support for dynamic arrays', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index, collection ) { - out.push( value ); - if ( index === collection.length-1 && collection.length < 10 ) { - collection.push( index+2 ); - } - } - - arr = [ 1, 2, 3 ]; - out = []; - - untilEach( arr, predicate, copy ); - - t.deepEqual( arr, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.deepEqual( out, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.end(); -}); - -tape( 'the function does not skip empty elements', function test( t ) { - var expected; - var arr; - - function predicate( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - return false; - } - - function verify( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - } - - arr = [ 1, , , 4 ]; // eslint-disable-line no-sparse-arrays - expected = [ 1, void 0, void 0, 4 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); - -tape( 'the function invokes the predicate function and the function to apply with three arguments: value, index, collection', function test( t ) { - var indices; - var values; - var arr; - - function predicate( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - return false; - } - - function verify( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - } - - arr = [ 1, 2, 3, 4 ]; - values = [ 1, 2, 3, 4 ]; - indices = [ 0, 1, 2, 3 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 70a1888..0000000 --- a/test/test.js +++ /dev/null @@ -1,350 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var untilEach = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof untilEach, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {}, - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( value, noop, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a predicate function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a function to invoke', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], noop, value ); - }; - } -}); - -tape( 'if provided an empty collection, the function never invokes a provided function', function test( t ) { - var arr = []; - - function predicate() { - t.fail( 'should not be invoked' ); - } - - function foo() { - t.fail( 'should not be invoked' ); - } - - untilEach( arr, predicate, foo ); - - t.deepEqual( arr, [], 'expected result' ); - t.end(); -}); - -tape( 'the function returns the input collection', function test( t ) { - var arr; - var out; - - function predicate() { - t.pass( 'invoked predicated function' ); - return false; - } - - function foo() { - t.pass( 'invoked provided function' ); - } - - arr = [ 1, 2, 3 ]; - - out = untilEach( arr, predicate, foo ); - - t.strictEqual( out, arr, 'returns input collection' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array)', function test( t ) { - var arr; - var out; - - arr = [ 1, 2, NaN, 3 ]; - out = [ 0, 0, 0, 0 ]; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - untilEach( arr, predicate, copy ); - - t.deepEqual( out, [ 1, 2, 0, 0 ], 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array-like object)', function test( t ) { - var expected; - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = { - 'length': 4, - '0': 1, - '1': 2, - '2': NaN, - '3': 3 - }; - out = { - 'length': 4, - '0': 0, - '1': 0, - '2': 0, - '3': 0 - }; - - untilEach( arr, predicate, copy ); - - expected = { - 'length': 4, - '0': 1, - '1': 2, - '2': 0, - '3': 0 - }; - - t.deepEqual( out, expected, 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (typed array)', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = new Float64Array( [ 1.0, 2.0, NaN, 3.0 ] ); - out = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - untilEach( arr, predicate, copy ); - - t.strictEqual( out[ 0 ], 1.0, 'expected result' ); - t.strictEqual( out[ 1 ], 2.0, 'expected result' ); - t.strictEqual( out[ 2 ], 0.0, 'expected result' ); - t.strictEqual( out[ 3 ], 0.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx; - var arr; - - function predicate( value ) { - return ( value !== value ); - } - - function sum( value ) { - /* eslint-disable no-invalid-this */ - this.sum += value; - this.count += 1; - } - - ctx = { - 'sum': 0, - 'count': 0 - }; - arr = [ 1.0, 2.0, 3.0 ]; - - untilEach( arr, predicate, sum, ctx ); - - t.strictEqual( ctx.sum/ctx.count, 2.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function provides basic support for dynamic arrays', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index, collection ) { - out.push( value ); - if ( index === collection.length-1 && collection.length < 10 ) { - collection.push( index+2 ); - } - } - - arr = [ 1, 2, 3 ]; - out = []; - - untilEach( arr, predicate, copy ); - - t.deepEqual( arr, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.deepEqual( out, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.end(); -}); - -tape( 'the function does not skip empty elements', function test( t ) { - var expected; - var arr; - - function predicate( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - return false; - } - - function verify( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - } - - arr = [ 1, , , 4 ]; // eslint-disable-line no-sparse-arrays - expected = [ 1, void 0, void 0, 4 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); - -tape( 'the function invokes the predicate function and the function to apply with three arguments: value, index, collection', function test( t ) { - var indices; - var values; - var arr; - - function predicate( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - return false; - } - - function verify( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - } - - arr = [ 1, 2, 3, 4 ]; - values = [ 1, 2, 3, 4 ]; - indices = [ 0, 1, 2, 3 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); From 2e63e940d219b2603671b6b89a03d23baa9f9128 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Nov 2023 07:54:48 +0000 Subject: [PATCH 067/135] 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 846d968..0cddcca 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,13 +56,13 @@ function untilEach( collection, predicate, fcn, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); + throw new TypeError( format( '1YDAh,O3', collection ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '1YD2H,G6', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '1YD3N,G4', fcn ) ); } len = collection.length; i = 0; diff --git a/package.json b/package.json index 04ea723..45e3e65 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-collection": "^0.1.0", "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.1.0" }, "devDependencies": { From 9f961d712b0d89980c66ed65091657a1b55ebbe8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 2 Nov 2023 13:09:29 +0000 Subject: [PATCH 068/135] Remove files --- index.d.ts | 142 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6324 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 355b4df..0000000 --- a/index.d.ts +++ /dev/null @@ -1,142 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Checks whether an element in a collection passes a test. -* -* @returns boolean indicating whether an element in a collection passes a test -*/ -type NullaryPredicate = () => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @returns boolean indicating whether an element in a collection passes a test -*/ -type UnaryPredicate = ( value: T ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @returns boolean indicating whether an element in a collection passes a test -*/ -type BinaryPredicate = ( value: T, index: number ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type TernaryPredicate = ( value: T, index: number, collection: Collection ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Predicate = NullaryPredicate | UnaryPredicate | BinaryPredicate | TernaryPredicate; - -/** -* Function invoked for each collection element until test condition is true. -*/ -type Nullary = ( this: U ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -*/ -type Unary = ( this: U, value: T ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -*/ -type Binary = ( this: U, value: T, index: number ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Ternary = ( this: U, value: T, index: number, collection: Collection ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Until a test condition is true, invokes a function once for each element in a collection. -* -* ## Notes -* -* - When invoked, both the predicate function and the function to apply are provided three arguments: -* -* - `value`: collection value -* - `index`: collection index -* - `collection`: the input collection -* -* @param collection - input collection -* @param predicate - function which indicates whether to stop iterating over a collection -* @param fcn - function to invoke -* @param thisArg - execution context for the applied function -* @returns input collection -* -* @example -* function predicate( v, key, collection ) { -* return ( v !== v ); -* } -* -* function log( v, key, collection ) { -* console.log( '%s: %d', key, v ); -* } -* -* var arr = [ 1, 2, 3, 4, NaN, 5 ]; -* -* untilEach( arr, predicate, log ); -*/ -declare function untilEach( collection: Collection, predicate: Predicate, fcn: Callback, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = untilEach; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ea85daa..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";function s(s,o,i,n){var d,l;if(!r(s))throw new TypeError(e("1YDAh,O3",s));if(!t(o))throw new TypeError(e("1YD2H,G6",o));if(!t(i))throw new TypeError(e("1YD3N,G4",i));for(d=s.length,l=0;l - - - - - - Rollup Visualizer - - - -
- - - - - From b95c53c4e6ac4febe0d5855af1fec86ca1208cd6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 2 Nov 2023 13:12:22 +0000 Subject: [PATCH 069/135] 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 | 43 +- benchmark/benchmark.js | 89 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 47 - docs/types/test.ts | 89 - examples/index.js | 53 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 83 - package.json | 61 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 350 -- 42 files changed, 6203 insertions(+), 4114 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 052aa3a..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-11-01T02:52:12.601Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 038a13c..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/utils/until-each) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 4eecda2..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/utils/until-each) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 9d21033..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: '35 11 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -293,7 +286,7 @@ untilEach( arr, predicate, log ); ## 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]. @@ -361,9 +354,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right +[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right/tree/esm -[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each +[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 16edfdb..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var untilEach = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var sum; - var i; - - function predicate( v ) { - return isnan( v ); - } - - function fcn( v ) { - sum += v; - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - untilEach( arr, predicate, fcn ); - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::loop', function benchmark( b ) { - var sum; - var arr; - var i; - var j; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - j = 0; - while ( j < arr.length ) { - if ( isnan( arr[ j ] ) ) { - break; - } - sum += arr[ j ]; - j += 1; - } - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 3a445ad..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/utils/until-each" -%% click B href "https://github.com/stdlib-js/utils-until-each/tree/main" -%% click C href "https://github.com/stdlib-js/utils-until-each/tree/production" -%% click D href "https://github.com/stdlib-js/utils-until-each/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-until-each/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-until-each/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/until-each -[production-url]: https://github.com/stdlib-js/utils-until-each/tree/production -[deno-url]: https://github.com/stdlib-js/utils-until-each/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-until-each/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-until-each/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 4378886..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import untilEach from '../docs/types/index'; -export = untilEach; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 52eaf73..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var g=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var m=g(function(E,s){ -var h=require('@stdlib/assert-is-collection/dist'),n=require('@stdlib/assert-is-function/dist'),i=require('@stdlib/error-tools-fmtprodmsg/dist');function w(r,e,a,v){var t,u;if(!h(r))throw new TypeError(i('1YDAh',r));if(!n(e))throw new TypeError(i('1YD2H',e));if(!n(a))throw new TypeError(i('1YD3N',a));for(t=r.length,u=0;u function predicate( v ) { return v !== v; }; - > function logger( v, i ) { console.log( '%s: %d', i, v ); }; - > var arr = [ 1, 2, 3, 4, NaN, 5 ]; - > {{alias}}( arr, predicate, logger ) - 0: 1 - 1: 2 - 2: 3 - 3: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4833283..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,89 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 untilEach = require( './index' ); - -/** -* Test function. -* -* @param v - value -* @param index - index -*/ -function fcn( v: number, index: number ): void { - if ( v !== v ) { - throw new Error( 'beep' ); - } - if ( index !== index ) { - throw new Error( 'beep' ); - } -} - -/** -* Test function. -* -* @param v - value -* @returns result -*/ -function isnan( v: number ): boolean { - return ( v !== v ); -} - - -// TESTS // - -// The function returns the input collection... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, fcn ); // $ExpectType Collection - untilEach( [ -1, 1, 2 ], isnan, fcn, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - untilEach( 2, isnan, fcn ); // $ExpectError - untilEach( false, isnan, fcn ); // $ExpectError - untilEach( true, isnan, fcn ); // $ExpectError - untilEach( {}, isnan, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], 2, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], false, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], true, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], 'abc', fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], {}, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], [], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, 2 ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, false ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, true ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, 'abc' ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, {} ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - untilEach(); // $ExpectError - untilEach( [ 1, 2, 3 ] ); // $ExpectError - untilEach( [ 1, 2, 3 ], isnan ); // $ExpectError - untilEach( [ 1, 2, 3 ], isnan, fcn, {}, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index c41d90c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isEven = require( '@stdlib/assert-is-even' ).isPrimitive; -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var untilEach = require( './../lib' ); - -function predicate( value ) { - return ( value !== value ); -} - -function log( value, index, collection ) { - console.log( '%s: %d', index, value ); - if ( isEven( index ) ) { - collection.shift(); - } else { - collection.push( index+1 ); - } -} - -var arr; -var j; -var i; - -arr = new Array( 100 ); -j = floor( randu()*arr.length ); -for ( i = 0; i < arr.length; i++ ) { - if ( i === j ) { - arr[ i ] = NaN; - } else { - arr[ i ] = i; - } -} - -untilEach( arr, predicate, log ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 19fe169..355b4df 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..ea85daa --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";function s(s,o,i,n){var d,l;if(!r(s))throw new TypeError(e("1YDAh,O3",s));if(!t(o))throw new TypeError(e("1YD2H,G6",o));if(!t(i))throw new TypeError(e("1YD3N,G4",i));for(d=s.length,l=0;l=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..cf8ee93 --- /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 70a1888..0000000 --- a/test/test.js +++ /dev/null @@ -1,350 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var untilEach = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof untilEach, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {}, - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( value, noop, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a predicate function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a function to invoke', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], noop, value ); - }; - } -}); - -tape( 'if provided an empty collection, the function never invokes a provided function', function test( t ) { - var arr = []; - - function predicate() { - t.fail( 'should not be invoked' ); - } - - function foo() { - t.fail( 'should not be invoked' ); - } - - untilEach( arr, predicate, foo ); - - t.deepEqual( arr, [], 'expected result' ); - t.end(); -}); - -tape( 'the function returns the input collection', function test( t ) { - var arr; - var out; - - function predicate() { - t.pass( 'invoked predicated function' ); - return false; - } - - function foo() { - t.pass( 'invoked provided function' ); - } - - arr = [ 1, 2, 3 ]; - - out = untilEach( arr, predicate, foo ); - - t.strictEqual( out, arr, 'returns input collection' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array)', function test( t ) { - var arr; - var out; - - arr = [ 1, 2, NaN, 3 ]; - out = [ 0, 0, 0, 0 ]; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - untilEach( arr, predicate, copy ); - - t.deepEqual( out, [ 1, 2, 0, 0 ], 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array-like object)', function test( t ) { - var expected; - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = { - 'length': 4, - '0': 1, - '1': 2, - '2': NaN, - '3': 3 - }; - out = { - 'length': 4, - '0': 0, - '1': 0, - '2': 0, - '3': 0 - }; - - untilEach( arr, predicate, copy ); - - expected = { - 'length': 4, - '0': 1, - '1': 2, - '2': 0, - '3': 0 - }; - - t.deepEqual( out, expected, 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (typed array)', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = new Float64Array( [ 1.0, 2.0, NaN, 3.0 ] ); - out = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - untilEach( arr, predicate, copy ); - - t.strictEqual( out[ 0 ], 1.0, 'expected result' ); - t.strictEqual( out[ 1 ], 2.0, 'expected result' ); - t.strictEqual( out[ 2 ], 0.0, 'expected result' ); - t.strictEqual( out[ 3 ], 0.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx; - var arr; - - function predicate( value ) { - return ( value !== value ); - } - - function sum( value ) { - /* eslint-disable no-invalid-this */ - this.sum += value; - this.count += 1; - } - - ctx = { - 'sum': 0, - 'count': 0 - }; - arr = [ 1.0, 2.0, 3.0 ]; - - untilEach( arr, predicate, sum, ctx ); - - t.strictEqual( ctx.sum/ctx.count, 2.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function provides basic support for dynamic arrays', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index, collection ) { - out.push( value ); - if ( index === collection.length-1 && collection.length < 10 ) { - collection.push( index+2 ); - } - } - - arr = [ 1, 2, 3 ]; - out = []; - - untilEach( arr, predicate, copy ); - - t.deepEqual( arr, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.deepEqual( out, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.end(); -}); - -tape( 'the function does not skip empty elements', function test( t ) { - var expected; - var arr; - - function predicate( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - return false; - } - - function verify( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - } - - arr = [ 1, , , 4 ]; // eslint-disable-line no-sparse-arrays - expected = [ 1, void 0, void 0, 4 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); - -tape( 'the function invokes the predicate function and the function to apply with three arguments: value, index, collection', function test( t ) { - var indices; - var values; - var arr; - - function predicate( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - return false; - } - - function verify( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - } - - arr = [ 1, 2, 3, 4 ]; - values = [ 1, 2, 3, 4 ]; - indices = [ 0, 1, 2, 3 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); From 8bb566d4f6fbb9ce560b3fe7e05b5ab8bde0b94a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Dec 2023 06:49:04 +0000 Subject: [PATCH 070/135] 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 846d968..0cddcca 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,13 +56,13 @@ function untilEach( collection, predicate, fcn, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); + throw new TypeError( format( '1YDAh,O3', collection ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '1YD2H,G6', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '1YD3N,G4', fcn ) ); } len = collection.length; i = 0; diff --git a/package.json b/package.json index 3531d43..2b5eb83 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-collection": "^0.1.0", "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.2.0" }, "devDependencies": { From 61435b8ad810657590f227edba48128c1d25ba3a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Dec 2023 01:41:10 +0000 Subject: [PATCH 071/135] Remove files --- index.d.ts | 142 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6324 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 355b4df..0000000 --- a/index.d.ts +++ /dev/null @@ -1,142 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Checks whether an element in a collection passes a test. -* -* @returns boolean indicating whether an element in a collection passes a test -*/ -type NullaryPredicate = () => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @returns boolean indicating whether an element in a collection passes a test -*/ -type UnaryPredicate = ( value: T ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @returns boolean indicating whether an element in a collection passes a test -*/ -type BinaryPredicate = ( value: T, index: number ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type TernaryPredicate = ( value: T, index: number, collection: Collection ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Predicate = NullaryPredicate | UnaryPredicate | BinaryPredicate | TernaryPredicate; - -/** -* Function invoked for each collection element until test condition is true. -*/ -type Nullary = ( this: U ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -*/ -type Unary = ( this: U, value: T ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -*/ -type Binary = ( this: U, value: T, index: number ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Ternary = ( this: U, value: T, index: number, collection: Collection ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Until a test condition is true, invokes a function once for each element in a collection. -* -* ## Notes -* -* - When invoked, both the predicate function and the function to apply are provided three arguments: -* -* - `value`: collection value -* - `index`: collection index -* - `collection`: the input collection -* -* @param collection - input collection -* @param predicate - function which indicates whether to stop iterating over a collection -* @param fcn - function to invoke -* @param thisArg - execution context for the applied function -* @returns input collection -* -* @example -* function predicate( v, key, collection ) { -* return ( v !== v ); -* } -* -* function log( v, key, collection ) { -* console.log( '%s: %d', key, v ); -* } -* -* var arr = [ 1, 2, 3, 4, NaN, 5 ]; -* -* untilEach( arr, predicate, log ); -*/ -declare function untilEach( collection: Collection, predicate: Predicate, fcn: Callback, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = untilEach; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ea85daa..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";function s(s,o,i,n){var d,l;if(!r(s))throw new TypeError(e("1YDAh,O3",s));if(!t(o))throw new TypeError(e("1YD2H,G6",o));if(!t(i))throw new TypeError(e("1YD3N,G4",i));for(d=s.length,l=0;l - - - - - - Rollup Visualizer - - - -
- - - - - From a3fb1e23536dd041486803e2dbad3c65d7f5d09c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Dec 2023 01:43:41 +0000 Subject: [PATCH 072/135] 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 | 43 +- benchmark/benchmark.js | 89 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 47 - docs/types/test.ts | 89 - examples/index.js | 53 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 83 - package.json | 61 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 350 -- 42 files changed, 6203 insertions(+), 4109 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index a1e1b2b..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-12-01T03:02:42.016Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 038a13c..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/utils/until-each) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 4eecda2..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/utils/until-each) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 9d21033..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: '35 11 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -293,7 +286,7 @@ untilEach( arr, predicate, log ); ## 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]. @@ -361,9 +354,9 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right +[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right/tree/esm -[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each +[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 16edfdb..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var untilEach = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var sum; - var i; - - function predicate( v ) { - return isnan( v ); - } - - function fcn( v ) { - sum += v; - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - untilEach( arr, predicate, fcn ); - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::loop', function benchmark( b ) { - var sum; - var arr; - var i; - var j; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - j = 0; - while ( j < arr.length ) { - if ( isnan( arr[ j ] ) ) { - break; - } - sum += arr[ j ]; - j += 1; - } - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 3a445ad..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/utils/until-each" -%% click B href "https://github.com/stdlib-js/utils-until-each/tree/main" -%% click C href "https://github.com/stdlib-js/utils-until-each/tree/production" -%% click D href "https://github.com/stdlib-js/utils-until-each/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-until-each/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-until-each/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/until-each -[production-url]: https://github.com/stdlib-js/utils-until-each/tree/production -[deno-url]: https://github.com/stdlib-js/utils-until-each/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-until-each/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-until-each/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 4378886..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import untilEach from '../docs/types/index'; -export = untilEach; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 52eaf73..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var g=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var m=g(function(E,s){ -var h=require('@stdlib/assert-is-collection/dist'),n=require('@stdlib/assert-is-function/dist'),i=require('@stdlib/error-tools-fmtprodmsg/dist');function w(r,e,a,v){var t,u;if(!h(r))throw new TypeError(i('1YDAh',r));if(!n(e))throw new TypeError(i('1YD2H',e));if(!n(a))throw new TypeError(i('1YD3N',a));for(t=r.length,u=0;u function predicate( v ) { return v !== v; }; - > function logger( v, i ) { console.log( '%s: %d', i, v ); }; - > var arr = [ 1, 2, 3, 4, NaN, 5 ]; - > {{alias}}( arr, predicate, logger ) - 0: 1 - 1: 2 - 2: 3 - 3: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4833283..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,89 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 untilEach = require( './index' ); - -/** -* Test function. -* -* @param v - value -* @param index - index -*/ -function fcn( v: number, index: number ): void { - if ( v !== v ) { - throw new Error( 'beep' ); - } - if ( index !== index ) { - throw new Error( 'beep' ); - } -} - -/** -* Test function. -* -* @param v - value -* @returns result -*/ -function isnan( v: number ): boolean { - return ( v !== v ); -} - - -// TESTS // - -// The function returns the input collection... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, fcn ); // $ExpectType Collection - untilEach( [ -1, 1, 2 ], isnan, fcn, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - untilEach( 2, isnan, fcn ); // $ExpectError - untilEach( false, isnan, fcn ); // $ExpectError - untilEach( true, isnan, fcn ); // $ExpectError - untilEach( {}, isnan, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], 2, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], false, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], true, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], 'abc', fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], {}, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], [], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, 2 ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, false ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, true ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, 'abc' ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, {} ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - untilEach(); // $ExpectError - untilEach( [ 1, 2, 3 ] ); // $ExpectError - untilEach( [ 1, 2, 3 ], isnan ); // $ExpectError - untilEach( [ 1, 2, 3 ], isnan, fcn, {}, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index c41d90c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isEven = require( '@stdlib/assert-is-even' ).isPrimitive; -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var untilEach = require( './../lib' ); - -function predicate( value ) { - return ( value !== value ); -} - -function log( value, index, collection ) { - console.log( '%s: %d', index, value ); - if ( isEven( index ) ) { - collection.shift(); - } else { - collection.push( index+1 ); - } -} - -var arr; -var j; -var i; - -arr = new Array( 100 ); -j = floor( randu()*arr.length ); -for ( i = 0; i < arr.length; i++ ) { - if ( i === j ) { - arr[ i ] = NaN; - } else { - arr[ i ] = i; - } -} - -untilEach( arr, predicate, log ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 19fe169..355b4df 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..ea85daa --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";function s(s,o,i,n){var d,l;if(!r(s))throw new TypeError(e("1YDAh,O3",s));if(!t(o))throw new TypeError(e("1YD2H,G6",o));if(!t(i))throw new TypeError(e("1YD3N,G4",i));for(d=s.length,l=0;l=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..64c8166 --- /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 70a1888..0000000 --- a/test/test.js +++ /dev/null @@ -1,350 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var untilEach = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof untilEach, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {}, - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( value, noop, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a predicate function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a function to invoke', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], noop, value ); - }; - } -}); - -tape( 'if provided an empty collection, the function never invokes a provided function', function test( t ) { - var arr = []; - - function predicate() { - t.fail( 'should not be invoked' ); - } - - function foo() { - t.fail( 'should not be invoked' ); - } - - untilEach( arr, predicate, foo ); - - t.deepEqual( arr, [], 'expected result' ); - t.end(); -}); - -tape( 'the function returns the input collection', function test( t ) { - var arr; - var out; - - function predicate() { - t.pass( 'invoked predicated function' ); - return false; - } - - function foo() { - t.pass( 'invoked provided function' ); - } - - arr = [ 1, 2, 3 ]; - - out = untilEach( arr, predicate, foo ); - - t.strictEqual( out, arr, 'returns input collection' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array)', function test( t ) { - var arr; - var out; - - arr = [ 1, 2, NaN, 3 ]; - out = [ 0, 0, 0, 0 ]; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - untilEach( arr, predicate, copy ); - - t.deepEqual( out, [ 1, 2, 0, 0 ], 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array-like object)', function test( t ) { - var expected; - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = { - 'length': 4, - '0': 1, - '1': 2, - '2': NaN, - '3': 3 - }; - out = { - 'length': 4, - '0': 0, - '1': 0, - '2': 0, - '3': 0 - }; - - untilEach( arr, predicate, copy ); - - expected = { - 'length': 4, - '0': 1, - '1': 2, - '2': 0, - '3': 0 - }; - - t.deepEqual( out, expected, 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (typed array)', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = new Float64Array( [ 1.0, 2.0, NaN, 3.0 ] ); - out = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - untilEach( arr, predicate, copy ); - - t.strictEqual( out[ 0 ], 1.0, 'expected result' ); - t.strictEqual( out[ 1 ], 2.0, 'expected result' ); - t.strictEqual( out[ 2 ], 0.0, 'expected result' ); - t.strictEqual( out[ 3 ], 0.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx; - var arr; - - function predicate( value ) { - return ( value !== value ); - } - - function sum( value ) { - /* eslint-disable no-invalid-this */ - this.sum += value; - this.count += 1; - } - - ctx = { - 'sum': 0, - 'count': 0 - }; - arr = [ 1.0, 2.0, 3.0 ]; - - untilEach( arr, predicate, sum, ctx ); - - t.strictEqual( ctx.sum/ctx.count, 2.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function provides basic support for dynamic arrays', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index, collection ) { - out.push( value ); - if ( index === collection.length-1 && collection.length < 10 ) { - collection.push( index+2 ); - } - } - - arr = [ 1, 2, 3 ]; - out = []; - - untilEach( arr, predicate, copy ); - - t.deepEqual( arr, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.deepEqual( out, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.end(); -}); - -tape( 'the function does not skip empty elements', function test( t ) { - var expected; - var arr; - - function predicate( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - return false; - } - - function verify( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - } - - arr = [ 1, , , 4 ]; // eslint-disable-line no-sparse-arrays - expected = [ 1, void 0, void 0, 4 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); - -tape( 'the function invokes the predicate function and the function to apply with three arguments: value, index, collection', function test( t ) { - var indices; - var values; - var arr; - - function predicate( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - return false; - } - - function verify( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - } - - arr = [ 1, 2, 3, 4 ]; - values = [ 1, 2, 3, 4 ]; - indices = [ 0, 1, 2, 3 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); From 50b3ac37ac2eb00ee75234326998ae5797dd0be0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 04:17:17 +0000 Subject: [PATCH 073/135] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7a11014..2047ed7 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-collection": "^0.1.0", "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.2.0" }, "devDependencies": { From ee7d0c45432335a333e0d3ab33292fa158c4367a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 10:26:06 +0000 Subject: [PATCH 074/135] Remove files --- index.d.ts | 142 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6324 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 355b4df..0000000 --- a/index.d.ts +++ /dev/null @@ -1,142 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Checks whether an element in a collection passes a test. -* -* @returns boolean indicating whether an element in a collection passes a test -*/ -type NullaryPredicate = () => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @returns boolean indicating whether an element in a collection passes a test -*/ -type UnaryPredicate = ( value: T ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @returns boolean indicating whether an element in a collection passes a test -*/ -type BinaryPredicate = ( value: T, index: number ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type TernaryPredicate = ( value: T, index: number, collection: Collection ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Predicate = NullaryPredicate | UnaryPredicate | BinaryPredicate | TernaryPredicate; - -/** -* Function invoked for each collection element until test condition is true. -*/ -type Nullary = ( this: U ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -*/ -type Unary = ( this: U, value: T ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -*/ -type Binary = ( this: U, value: T, index: number ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Ternary = ( this: U, value: T, index: number, collection: Collection ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Until a test condition is true, invokes a function once for each element in a collection. -* -* ## Notes -* -* - When invoked, both the predicate function and the function to apply are provided three arguments: -* -* - `value`: collection value -* - `index`: collection index -* - `collection`: the input collection -* -* @param collection - input collection -* @param predicate - function which indicates whether to stop iterating over a collection -* @param fcn - function to invoke -* @param thisArg - execution context for the applied function -* @returns input collection -* -* @example -* function predicate( v, key, collection ) { -* return ( v !== v ); -* } -* -* function log( v, key, collection ) { -* console.log( '%s: %d', key, v ); -* } -* -* var arr = [ 1, 2, 3, 4, NaN, 5 ]; -* -* untilEach( arr, predicate, log ); -*/ -declare function untilEach( collection: Collection, predicate: Predicate, fcn: Callback, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = untilEach; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ea85daa..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";function s(s,o,i,n){var d,l;if(!r(s))throw new TypeError(e("1YDAh,O3",s));if(!t(o))throw new TypeError(e("1YD2H,G6",o));if(!t(i))throw new TypeError(e("1YD3N,G4",i));for(d=s.length,l=0;l - - - - - - Rollup Visualizer - - - -
- - - - - From 874d7ac697d5a344fc1955ca5e7bdce60b4cab0c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 10:26:26 +0000 Subject: [PATCH 075/135] 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 | 43 +- SECURITY.md | 5 - benchmark/benchmark.js | 89 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 47 - docs/types/test.ts | 89 - examples/index.js | 53 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 83 - package.json | 61 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 350 -- 43 files changed, 6203 insertions(+), 4115 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index c820d22..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-01-01T02:37:46.326Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 038a13c..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/utils/until-each) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 4eecda2..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/utils/until-each) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 ac5c73f..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: '35 11 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index e1e3539..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -293,7 +286,7 @@ untilEach( arr, predicate, log ); ## 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]. @@ -361,9 +354,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right +[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right/tree/esm -[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each +[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each/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 754724d..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var untilEach = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var sum; - var i; - - function predicate( v ) { - return isnan( v ); - } - - function fcn( v ) { - sum += v; - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - untilEach( arr, predicate, fcn ); - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::loop', function benchmark( b ) { - var sum; - var arr; - var i; - var j; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - j = 0; - while ( j < arr.length ) { - if ( isnan( arr[ j ] ) ) { - break; - } - sum += arr[ j ]; - j += 1; - } - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 3a445ad..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/utils/until-each" -%% click B href "https://github.com/stdlib-js/utils-until-each/tree/main" -%% click C href "https://github.com/stdlib-js/utils-until-each/tree/production" -%% click D href "https://github.com/stdlib-js/utils-until-each/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-until-each/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-until-each/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/until-each -[production-url]: https://github.com/stdlib-js/utils-until-each/tree/production -[deno-url]: https://github.com/stdlib-js/utils-until-each/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-until-each/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-until-each/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 4378886..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import untilEach from '../docs/types/index'; -export = untilEach; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 52eaf73..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var g=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var m=g(function(E,s){ -var h=require('@stdlib/assert-is-collection/dist'),n=require('@stdlib/assert-is-function/dist'),i=require('@stdlib/error-tools-fmtprodmsg/dist');function w(r,e,a,v){var t,u;if(!h(r))throw new TypeError(i('1YDAh',r));if(!n(e))throw new TypeError(i('1YD2H',e));if(!n(a))throw new TypeError(i('1YD3N',a));for(t=r.length,u=0;u function predicate( v ) { return v !== v; }; - > function logger( v, i ) { console.log( '%s: %d', i, v ); }; - > var arr = [ 1, 2, 3, 4, NaN, 5 ]; - > {{alias}}( arr, predicate, logger ) - 0: 1 - 1: 2 - 2: 3 - 3: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4833283..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,89 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 untilEach = require( './index' ); - -/** -* Test function. -* -* @param v - value -* @param index - index -*/ -function fcn( v: number, index: number ): void { - if ( v !== v ) { - throw new Error( 'beep' ); - } - if ( index !== index ) { - throw new Error( 'beep' ); - } -} - -/** -* Test function. -* -* @param v - value -* @returns result -*/ -function isnan( v: number ): boolean { - return ( v !== v ); -} - - -// TESTS // - -// The function returns the input collection... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, fcn ); // $ExpectType Collection - untilEach( [ -1, 1, 2 ], isnan, fcn, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - untilEach( 2, isnan, fcn ); // $ExpectError - untilEach( false, isnan, fcn ); // $ExpectError - untilEach( true, isnan, fcn ); // $ExpectError - untilEach( {}, isnan, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], 2, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], false, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], true, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], 'abc', fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], {}, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], [], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, 2 ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, false ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, true ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, 'abc' ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, {} ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - untilEach(); // $ExpectError - untilEach( [ 1, 2, 3 ] ); // $ExpectError - untilEach( [ 1, 2, 3 ], isnan ); // $ExpectError - untilEach( [ 1, 2, 3 ], isnan, fcn, {}, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index c41d90c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isEven = require( '@stdlib/assert-is-even' ).isPrimitive; -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var untilEach = require( './../lib' ); - -function predicate( value ) { - return ( value !== value ); -} - -function log( value, index, collection ) { - console.log( '%s: %d', index, value ); - if ( isEven( index ) ) { - collection.shift(); - } else { - collection.push( index+1 ); - } -} - -var arr; -var j; -var i; - -arr = new Array( 100 ); -j = floor( randu()*arr.length ); -for ( i = 0; i < arr.length; i++ ) { - if ( i === j ) { - arr[ i ] = NaN; - } else { - arr[ i ] = i; - } -} - -untilEach( arr, predicate, log ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 19fe169..355b4df 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..dbc4048 --- /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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function n(n,s,i,o){var a,m;if(!t(n))throw new TypeError(r("invalid argument. First argument must be a collection. Value: `%s`.",n));if(!e(s))throw new TypeError(r("invalid argument. Second argument must be a function. Value: `%s`.",s));if(!e(i))throw new TypeError(r("invalid argument. Third argument must be a function. Value: `%s`.",i));for(a=n.length,m=0;m=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..313b8ce --- /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 70a1888..0000000 --- a/test/test.js +++ /dev/null @@ -1,350 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var untilEach = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof untilEach, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {}, - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( value, noop, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a predicate function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a function to invoke', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], noop, value ); - }; - } -}); - -tape( 'if provided an empty collection, the function never invokes a provided function', function test( t ) { - var arr = []; - - function predicate() { - t.fail( 'should not be invoked' ); - } - - function foo() { - t.fail( 'should not be invoked' ); - } - - untilEach( arr, predicate, foo ); - - t.deepEqual( arr, [], 'expected result' ); - t.end(); -}); - -tape( 'the function returns the input collection', function test( t ) { - var arr; - var out; - - function predicate() { - t.pass( 'invoked predicated function' ); - return false; - } - - function foo() { - t.pass( 'invoked provided function' ); - } - - arr = [ 1, 2, 3 ]; - - out = untilEach( arr, predicate, foo ); - - t.strictEqual( out, arr, 'returns input collection' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array)', function test( t ) { - var arr; - var out; - - arr = [ 1, 2, NaN, 3 ]; - out = [ 0, 0, 0, 0 ]; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - untilEach( arr, predicate, copy ); - - t.deepEqual( out, [ 1, 2, 0, 0 ], 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array-like object)', function test( t ) { - var expected; - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = { - 'length': 4, - '0': 1, - '1': 2, - '2': NaN, - '3': 3 - }; - out = { - 'length': 4, - '0': 0, - '1': 0, - '2': 0, - '3': 0 - }; - - untilEach( arr, predicate, copy ); - - expected = { - 'length': 4, - '0': 1, - '1': 2, - '2': 0, - '3': 0 - }; - - t.deepEqual( out, expected, 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (typed array)', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = new Float64Array( [ 1.0, 2.0, NaN, 3.0 ] ); - out = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - untilEach( arr, predicate, copy ); - - t.strictEqual( out[ 0 ], 1.0, 'expected result' ); - t.strictEqual( out[ 1 ], 2.0, 'expected result' ); - t.strictEqual( out[ 2 ], 0.0, 'expected result' ); - t.strictEqual( out[ 3 ], 0.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx; - var arr; - - function predicate( value ) { - return ( value !== value ); - } - - function sum( value ) { - /* eslint-disable no-invalid-this */ - this.sum += value; - this.count += 1; - } - - ctx = { - 'sum': 0, - 'count': 0 - }; - arr = [ 1.0, 2.0, 3.0 ]; - - untilEach( arr, predicate, sum, ctx ); - - t.strictEqual( ctx.sum/ctx.count, 2.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function provides basic support for dynamic arrays', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index, collection ) { - out.push( value ); - if ( index === collection.length-1 && collection.length < 10 ) { - collection.push( index+2 ); - } - } - - arr = [ 1, 2, 3 ]; - out = []; - - untilEach( arr, predicate, copy ); - - t.deepEqual( arr, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.deepEqual( out, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.end(); -}); - -tape( 'the function does not skip empty elements', function test( t ) { - var expected; - var arr; - - function predicate( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - return false; - } - - function verify( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - } - - arr = [ 1, , , 4 ]; // eslint-disable-line no-sparse-arrays - expected = [ 1, void 0, void 0, 4 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); - -tape( 'the function invokes the predicate function and the function to apply with three arguments: value, index, collection', function test( t ) { - var indices; - var values; - var arr; - - function predicate( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - return false; - } - - function verify( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - } - - arr = [ 1, 2, 3, 4 ]; - values = [ 1, 2, 3, 4 ]; - indices = [ 0, 1, 2, 3 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); From 2b70d03d50d729d7fcfdd67928334906764a07f6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 04:40:04 +0000 Subject: [PATCH 076/135] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7a11014..2047ed7 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-collection": "^0.1.0", "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.2.0" }, "devDependencies": { From e2379021b6e4c336428880409c3506cbc74573ae Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 09:53:01 +0000 Subject: [PATCH 077/135] Remove files --- index.d.ts | 142 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6324 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 355b4df..0000000 --- a/index.d.ts +++ /dev/null @@ -1,142 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Checks whether an element in a collection passes a test. -* -* @returns boolean indicating whether an element in a collection passes a test -*/ -type NullaryPredicate = () => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @returns boolean indicating whether an element in a collection passes a test -*/ -type UnaryPredicate = ( value: T ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @returns boolean indicating whether an element in a collection passes a test -*/ -type BinaryPredicate = ( value: T, index: number ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type TernaryPredicate = ( value: T, index: number, collection: Collection ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Predicate = NullaryPredicate | UnaryPredicate | BinaryPredicate | TernaryPredicate; - -/** -* Function invoked for each collection element until test condition is true. -*/ -type Nullary = ( this: U ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -*/ -type Unary = ( this: U, value: T ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -*/ -type Binary = ( this: U, value: T, index: number ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Ternary = ( this: U, value: T, index: number, collection: Collection ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Until a test condition is true, invokes a function once for each element in a collection. -* -* ## Notes -* -* - When invoked, both the predicate function and the function to apply are provided three arguments: -* -* - `value`: collection value -* - `index`: collection index -* - `collection`: the input collection -* -* @param collection - input collection -* @param predicate - function which indicates whether to stop iterating over a collection -* @param fcn - function to invoke -* @param thisArg - execution context for the applied function -* @returns input collection -* -* @example -* function predicate( v, key, collection ) { -* return ( v !== v ); -* } -* -* function log( v, key, collection ) { -* console.log( '%s: %d', key, v ); -* } -* -* var arr = [ 1, 2, 3, 4, NaN, 5 ]; -* -* untilEach( arr, predicate, log ); -*/ -declare function untilEach( collection: Collection, predicate: Predicate, fcn: Callback, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = untilEach; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index dbc4048..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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function n(n,s,i,o){var a,m;if(!t(n))throw new TypeError(r("invalid argument. First argument must be a collection. Value: `%s`.",n));if(!e(s))throw new TypeError(r("invalid argument. Second argument must be a function. Value: `%s`.",s));if(!e(i))throw new TypeError(r("invalid argument. Third argument must be a function. Value: `%s`.",i));for(a=n.length,m=0;m - - - - - - Rollup Visualizer - - - -
- - - - - From ccc063ad88e8662cc136c8efdf6e6112397d212b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 09:53:19 +0000 Subject: [PATCH 078/135] 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 | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 89 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 47 - docs/types/test.ts | 89 - examples/index.js | 53 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 83 - package.json | 61 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 350 -- 43 files changed, 6203 insertions(+), 4120 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 7b40a05..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-02-01T03:09:30.117Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 038a13c..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/utils/until-each) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 4eecda2..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/utils/until-each) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 ac5c73f..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: '35 11 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index e1e3539..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -295,7 +286,7 @@ untilEach( arr, predicate, log ); ## 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]. @@ -366,9 +357,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right +[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right/tree/esm -[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each +[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each/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 754724d..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var untilEach = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var sum; - var i; - - function predicate( v ) { - return isnan( v ); - } - - function fcn( v ) { - sum += v; - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - untilEach( arr, predicate, fcn ); - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::loop', function benchmark( b ) { - var sum; - var arr; - var i; - var j; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - j = 0; - while ( j < arr.length ) { - if ( isnan( arr[ j ] ) ) { - break; - } - sum += arr[ j ]; - j += 1; - } - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 5ae3876..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/utils/until-each" -%% click B href "https://github.com/stdlib-js/utils-until-each/tree/main" -%% click C href "https://github.com/stdlib-js/utils-until-each/tree/production" -%% click D href "https://github.com/stdlib-js/utils-until-each/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-until-each/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-until-each/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/until-each -[production-url]: https://github.com/stdlib-js/utils-until-each/tree/production -[deno-url]: https://github.com/stdlib-js/utils-until-each/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-until-each/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-until-each/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-until-each/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-until-each/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-until-each/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 4378886..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import untilEach from '../docs/types/index'; -export = untilEach; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 52eaf73..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var g=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var m=g(function(E,s){ -var h=require('@stdlib/assert-is-collection/dist'),n=require('@stdlib/assert-is-function/dist'),i=require('@stdlib/error-tools-fmtprodmsg/dist');function w(r,e,a,v){var t,u;if(!h(r))throw new TypeError(i('1YDAh',r));if(!n(e))throw new TypeError(i('1YD2H',e));if(!n(a))throw new TypeError(i('1YD3N',a));for(t=r.length,u=0;u function predicate( v ) { return v !== v; }; - > function logger( v, i ) { console.log( '%s: %d', i, v ); }; - > var arr = [ 1, 2, 3, 4, NaN, 5 ]; - > {{alias}}( arr, predicate, logger ) - 0: 1 - 1: 2 - 2: 3 - 3: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4833283..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,89 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 untilEach = require( './index' ); - -/** -* Test function. -* -* @param v - value -* @param index - index -*/ -function fcn( v: number, index: number ): void { - if ( v !== v ) { - throw new Error( 'beep' ); - } - if ( index !== index ) { - throw new Error( 'beep' ); - } -} - -/** -* Test function. -* -* @param v - value -* @returns result -*/ -function isnan( v: number ): boolean { - return ( v !== v ); -} - - -// TESTS // - -// The function returns the input collection... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, fcn ); // $ExpectType Collection - untilEach( [ -1, 1, 2 ], isnan, fcn, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - untilEach( 2, isnan, fcn ); // $ExpectError - untilEach( false, isnan, fcn ); // $ExpectError - untilEach( true, isnan, fcn ); // $ExpectError - untilEach( {}, isnan, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], 2, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], false, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], true, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], 'abc', fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], {}, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], [], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, 2 ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, false ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, true ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, 'abc' ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, {} ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - untilEach(); // $ExpectError - untilEach( [ 1, 2, 3 ] ); // $ExpectError - untilEach( [ 1, 2, 3 ], isnan ); // $ExpectError - untilEach( [ 1, 2, 3 ], isnan, fcn, {}, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index c41d90c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isEven = require( '@stdlib/assert-is-even' ).isPrimitive; -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var untilEach = require( './../lib' ); - -function predicate( value ) { - return ( value !== value ); -} - -function log( value, index, collection ) { - console.log( '%s: %d', index, value ); - if ( isEven( index ) ) { - collection.shift(); - } else { - collection.push( index+1 ); - } -} - -var arr; -var j; -var i; - -arr = new Array( 100 ); -j = floor( randu()*arr.length ); -for ( i = 0; i < arr.length; i++ ) { - if ( i === j ) { - arr[ i ] = NaN; - } else { - arr[ i ] = i; - } -} - -untilEach( arr, predicate, log ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 19fe169..355b4df 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..dbc4048 --- /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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function n(n,s,i,o){var a,m;if(!t(n))throw new TypeError(r("invalid argument. First argument must be a collection. Value: `%s`.",n));if(!e(s))throw new TypeError(r("invalid argument. Second argument must be a function. Value: `%s`.",s));if(!e(i))throw new TypeError(r("invalid argument. Third argument must be a function. Value: `%s`.",i));for(a=n.length,m=0;m=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..52ac5d0 --- /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 70a1888..0000000 --- a/test/test.js +++ /dev/null @@ -1,350 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var untilEach = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof untilEach, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {}, - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( value, noop, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a predicate function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a function to invoke', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], noop, value ); - }; - } -}); - -tape( 'if provided an empty collection, the function never invokes a provided function', function test( t ) { - var arr = []; - - function predicate() { - t.fail( 'should not be invoked' ); - } - - function foo() { - t.fail( 'should not be invoked' ); - } - - untilEach( arr, predicate, foo ); - - t.deepEqual( arr, [], 'expected result' ); - t.end(); -}); - -tape( 'the function returns the input collection', function test( t ) { - var arr; - var out; - - function predicate() { - t.pass( 'invoked predicated function' ); - return false; - } - - function foo() { - t.pass( 'invoked provided function' ); - } - - arr = [ 1, 2, 3 ]; - - out = untilEach( arr, predicate, foo ); - - t.strictEqual( out, arr, 'returns input collection' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array)', function test( t ) { - var arr; - var out; - - arr = [ 1, 2, NaN, 3 ]; - out = [ 0, 0, 0, 0 ]; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - untilEach( arr, predicate, copy ); - - t.deepEqual( out, [ 1, 2, 0, 0 ], 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array-like object)', function test( t ) { - var expected; - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = { - 'length': 4, - '0': 1, - '1': 2, - '2': NaN, - '3': 3 - }; - out = { - 'length': 4, - '0': 0, - '1': 0, - '2': 0, - '3': 0 - }; - - untilEach( arr, predicate, copy ); - - expected = { - 'length': 4, - '0': 1, - '1': 2, - '2': 0, - '3': 0 - }; - - t.deepEqual( out, expected, 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (typed array)', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = new Float64Array( [ 1.0, 2.0, NaN, 3.0 ] ); - out = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - untilEach( arr, predicate, copy ); - - t.strictEqual( out[ 0 ], 1.0, 'expected result' ); - t.strictEqual( out[ 1 ], 2.0, 'expected result' ); - t.strictEqual( out[ 2 ], 0.0, 'expected result' ); - t.strictEqual( out[ 3 ], 0.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx; - var arr; - - function predicate( value ) { - return ( value !== value ); - } - - function sum( value ) { - /* eslint-disable no-invalid-this */ - this.sum += value; - this.count += 1; - } - - ctx = { - 'sum': 0, - 'count': 0 - }; - arr = [ 1.0, 2.0, 3.0 ]; - - untilEach( arr, predicate, sum, ctx ); - - t.strictEqual( ctx.sum/ctx.count, 2.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function provides basic support for dynamic arrays', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index, collection ) { - out.push( value ); - if ( index === collection.length-1 && collection.length < 10 ) { - collection.push( index+2 ); - } - } - - arr = [ 1, 2, 3 ]; - out = []; - - untilEach( arr, predicate, copy ); - - t.deepEqual( arr, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.deepEqual( out, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.end(); -}); - -tape( 'the function does not skip empty elements', function test( t ) { - var expected; - var arr; - - function predicate( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - return false; - } - - function verify( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - } - - arr = [ 1, , , 4 ]; // eslint-disable-line no-sparse-arrays - expected = [ 1, void 0, void 0, 4 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); - -tape( 'the function invokes the predicate function and the function to apply with three arguments: value, index, collection', function test( t ) { - var indices; - var values; - var arr; - - function predicate( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - return false; - } - - function verify( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - } - - arr = [ 1, 2, 3, 4 ]; - values = [ 1, 2, 3, 4 ]; - indices = [ 0, 1, 2, 3 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); From 03930cbbf88c85e78dc5de984b4f9945dc1cedd2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 08:31:42 +0000 Subject: [PATCH 079/135] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 958b634..3c30c75 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-collection": "^0.2.0", "@stdlib/assert-is-function": "^0.2.0", - "@stdlib/string-format": "^0.2.0", + "@stdlib/error-tools-fmtprodmsg": "^0.2.0", "@stdlib/types": "^0.3.1" }, "devDependencies": { From c484ef6360931bd7af3914bfe3b2e1a2a1b20bae Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 16:57:46 +0000 Subject: [PATCH 080/135] Remove files --- index.d.ts | 142 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6324 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 355b4df..0000000 --- a/index.d.ts +++ /dev/null @@ -1,142 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Checks whether an element in a collection passes a test. -* -* @returns boolean indicating whether an element in a collection passes a test -*/ -type NullaryPredicate = () => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @returns boolean indicating whether an element in a collection passes a test -*/ -type UnaryPredicate = ( value: T ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @returns boolean indicating whether an element in a collection passes a test -*/ -type BinaryPredicate = ( value: T, index: number ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type TernaryPredicate = ( value: T, index: number, collection: Collection ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Predicate = NullaryPredicate | UnaryPredicate | BinaryPredicate | TernaryPredicate; - -/** -* Function invoked for each collection element until test condition is true. -*/ -type Nullary = ( this: U ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -*/ -type Unary = ( this: U, value: T ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -*/ -type Binary = ( this: U, value: T, index: number ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Ternary = ( this: U, value: T, index: number, collection: Collection ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Until a test condition is true, invokes a function once for each element in a collection. -* -* ## Notes -* -* - When invoked, both the predicate function and the function to apply are provided three arguments: -* -* - `value`: collection value -* - `index`: collection index -* - `collection`: the input collection -* -* @param collection - input collection -* @param predicate - function which indicates whether to stop iterating over a collection -* @param fcn - function to invoke -* @param thisArg - execution context for the applied function -* @returns input collection -* -* @example -* function predicate( v, key, collection ) { -* return ( v !== v ); -* } -* -* function log( v, key, collection ) { -* console.log( '%s: %d', key, v ); -* } -* -* var arr = [ 1, 2, 3, 4, NaN, 5 ]; -* -* untilEach( arr, predicate, log ); -*/ -declare function untilEach( collection: Collection, predicate: Predicate, fcn: Callback, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = untilEach; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index dbc4048..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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function n(n,s,i,o){var a,m;if(!t(n))throw new TypeError(r("invalid argument. First argument must be a collection. Value: `%s`.",n));if(!e(s))throw new TypeError(r("invalid argument. Second argument must be a function. Value: `%s`.",s));if(!e(i))throw new TypeError(r("invalid argument. Third argument must be a function. Value: `%s`.",i));for(a=n.length,m=0;m - - - - - - Rollup Visualizer - - - -
- - - - - From 616565241985ad6f226e9cfae0d03fc886d636c5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 16:58:06 +0000 Subject: [PATCH 081/135] 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 | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 89 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 47 - docs/types/test.ts | 89 - examples/index.js | 53 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 83 - package.json | 61 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 350 -- 42 files changed, 6203 insertions(+), 4123 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 038a13c..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/utils/until-each) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 4eecda2..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/utils/until-each) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 24e0f47..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: '35 11 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 9106b5d..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -295,7 +286,7 @@ untilEach( arr, predicate, log ); ## 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]. @@ -366,9 +357,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right +[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right/tree/esm -[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each +[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each/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 754724d..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var untilEach = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var sum; - var i; - - function predicate( v ) { - return isnan( v ); - } - - function fcn( v ) { - sum += v; - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - untilEach( arr, predicate, fcn ); - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::loop', function benchmark( b ) { - var sum; - var arr; - var i; - var j; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - j = 0; - while ( j < arr.length ) { - if ( isnan( arr[ j ] ) ) { - break; - } - sum += arr[ j ]; - j += 1; - } - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 5ae3876..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/utils/until-each" -%% click B href "https://github.com/stdlib-js/utils-until-each/tree/main" -%% click C href "https://github.com/stdlib-js/utils-until-each/tree/production" -%% click D href "https://github.com/stdlib-js/utils-until-each/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-until-each/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-until-each/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/until-each -[production-url]: https://github.com/stdlib-js/utils-until-each/tree/production -[deno-url]: https://github.com/stdlib-js/utils-until-each/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-until-each/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-until-each/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-until-each/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-until-each/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-until-each/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 4378886..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import untilEach from '../docs/types/index'; -export = untilEach; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 52eaf73..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var g=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var m=g(function(E,s){ -var h=require('@stdlib/assert-is-collection/dist'),n=require('@stdlib/assert-is-function/dist'),i=require('@stdlib/error-tools-fmtprodmsg/dist');function w(r,e,a,v){var t,u;if(!h(r))throw new TypeError(i('1YDAh',r));if(!n(e))throw new TypeError(i('1YD2H',e));if(!n(a))throw new TypeError(i('1YD3N',a));for(t=r.length,u=0;u function predicate( v ) { return v !== v; }; - > function logger( v, i ) { console.log( '%s: %d', i, v ); }; - > var arr = [ 1, 2, 3, 4, NaN, 5 ]; - > {{alias}}( arr, predicate, logger ) - 0: 1 - 1: 2 - 2: 3 - 3: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4833283..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,89 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 untilEach = require( './index' ); - -/** -* Test function. -* -* @param v - value -* @param index - index -*/ -function fcn( v: number, index: number ): void { - if ( v !== v ) { - throw new Error( 'beep' ); - } - if ( index !== index ) { - throw new Error( 'beep' ); - } -} - -/** -* Test function. -* -* @param v - value -* @returns result -*/ -function isnan( v: number ): boolean { - return ( v !== v ); -} - - -// TESTS // - -// The function returns the input collection... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, fcn ); // $ExpectType Collection - untilEach( [ -1, 1, 2 ], isnan, fcn, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - untilEach( 2, isnan, fcn ); // $ExpectError - untilEach( false, isnan, fcn ); // $ExpectError - untilEach( true, isnan, fcn ); // $ExpectError - untilEach( {}, isnan, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], 2, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], false, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], true, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], 'abc', fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], {}, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], [], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, 2 ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, false ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, true ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, 'abc' ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, {} ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - untilEach(); // $ExpectError - untilEach( [ 1, 2, 3 ] ); // $ExpectError - untilEach( [ 1, 2, 3 ], isnan ); // $ExpectError - untilEach( [ 1, 2, 3 ], isnan, fcn, {}, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index c41d90c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isEven = require( '@stdlib/assert-is-even' ).isPrimitive; -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var untilEach = require( './../lib' ); - -function predicate( value ) { - return ( value !== value ); -} - -function log( value, index, collection ) { - console.log( '%s: %d', index, value ); - if ( isEven( index ) ) { - collection.shift(); - } else { - collection.push( index+1 ); - } -} - -var arr; -var j; -var i; - -arr = new Array( 100 ); -j = floor( randu()*arr.length ); -for ( i = 0; i < arr.length; i++ ) { - if ( i === j ) { - arr[ i ] = NaN; - } else { - arr[ i ] = i; - } -} - -untilEach( arr, predicate, log ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 19fe169..355b4df 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..52a0310 --- /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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function n(n,s,i,o){var a,m;if(!t(n))throw new TypeError(r("invalid argument. First argument must be a collection. Value: `%s`.",n));if(!e(s))throw new TypeError(r("invalid argument. Second argument must be a function. Value: `%s`.",s));if(!e(i))throw new TypeError(r("invalid argument. Third argument must be a function. Value: `%s`.",i));for(a=n.length,m=0;m=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..bd97823 --- /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 70a1888..0000000 --- a/test/test.js +++ /dev/null @@ -1,350 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var untilEach = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof untilEach, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {}, - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( value, noop, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a predicate function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a function to invoke', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], noop, value ); - }; - } -}); - -tape( 'if provided an empty collection, the function never invokes a provided function', function test( t ) { - var arr = []; - - function predicate() { - t.fail( 'should not be invoked' ); - } - - function foo() { - t.fail( 'should not be invoked' ); - } - - untilEach( arr, predicate, foo ); - - t.deepEqual( arr, [], 'expected result' ); - t.end(); -}); - -tape( 'the function returns the input collection', function test( t ) { - var arr; - var out; - - function predicate() { - t.pass( 'invoked predicated function' ); - return false; - } - - function foo() { - t.pass( 'invoked provided function' ); - } - - arr = [ 1, 2, 3 ]; - - out = untilEach( arr, predicate, foo ); - - t.strictEqual( out, arr, 'returns input collection' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array)', function test( t ) { - var arr; - var out; - - arr = [ 1, 2, NaN, 3 ]; - out = [ 0, 0, 0, 0 ]; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - untilEach( arr, predicate, copy ); - - t.deepEqual( out, [ 1, 2, 0, 0 ], 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array-like object)', function test( t ) { - var expected; - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = { - 'length': 4, - '0': 1, - '1': 2, - '2': NaN, - '3': 3 - }; - out = { - 'length': 4, - '0': 0, - '1': 0, - '2': 0, - '3': 0 - }; - - untilEach( arr, predicate, copy ); - - expected = { - 'length': 4, - '0': 1, - '1': 2, - '2': 0, - '3': 0 - }; - - t.deepEqual( out, expected, 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (typed array)', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = new Float64Array( [ 1.0, 2.0, NaN, 3.0 ] ); - out = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - untilEach( arr, predicate, copy ); - - t.strictEqual( out[ 0 ], 1.0, 'expected result' ); - t.strictEqual( out[ 1 ], 2.0, 'expected result' ); - t.strictEqual( out[ 2 ], 0.0, 'expected result' ); - t.strictEqual( out[ 3 ], 0.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx; - var arr; - - function predicate( value ) { - return ( value !== value ); - } - - function sum( value ) { - /* eslint-disable no-invalid-this */ - this.sum += value; - this.count += 1; - } - - ctx = { - 'sum': 0, - 'count': 0 - }; - arr = [ 1.0, 2.0, 3.0 ]; - - untilEach( arr, predicate, sum, ctx ); - - t.strictEqual( ctx.sum/ctx.count, 2.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function provides basic support for dynamic arrays', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index, collection ) { - out.push( value ); - if ( index === collection.length-1 && collection.length < 10 ) { - collection.push( index+2 ); - } - } - - arr = [ 1, 2, 3 ]; - out = []; - - untilEach( arr, predicate, copy ); - - t.deepEqual( arr, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.deepEqual( out, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.end(); -}); - -tape( 'the function does not skip empty elements', function test( t ) { - var expected; - var arr; - - function predicate( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - return false; - } - - function verify( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - } - - arr = [ 1, , , 4 ]; // eslint-disable-line no-sparse-arrays - expected = [ 1, void 0, void 0, 4 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); - -tape( 'the function invokes the predicate function and the function to apply with three arguments: value, index, collection', function test( t ) { - var indices; - var values; - var arr; - - function predicate( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - return false; - } - - function verify( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - } - - arr = [ 1, 2, 3, 4 ]; - values = [ 1, 2, 3, 4 ]; - indices = [ 0, 1, 2, 3 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); From 39dc34e41a661cffbfc9000d1cc8a645f11095e1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 20:12:51 +0000 Subject: [PATCH 082/135] 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 8926bb6..d2a55d5 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import untilEach from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-until-each@esm/index.mjs'; +import untilEach from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-until-each@v0.2.0-esm/index.mjs'; ``` #### untilEach( collection, predicate, fcn\[, thisArg ] ) @@ -214,7 +214,7 @@ var mean = context.sum / context.count; var isEven = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-even' ).isPrimitive; import randu from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-randu@esm/index.mjs'; import floor from 'https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@esm/index.mjs'; -import untilEach from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-until-each@esm/index.mjs'; +import untilEach from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-until-each@v0.2.0-esm/index.mjs'; function predicate( value ) { return ( value !== value ); From 8f23db0188692cdda0770397bdf5bbc62e6dd51d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 20:12:51 +0000 Subject: [PATCH 083/135] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d2a55d5..5169cbc 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ limitations under the License. ## Usage +```javascript +import untilEach from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-until-each@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/utils-until-each/tags). For example, + ```javascript import untilEach from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-until-each@v0.2.0-esm/index.mjs'; ``` @@ -214,7 +219,7 @@ var mean = context.sum / context.count; var isEven = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-even' ).isPrimitive; import randu from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-randu@esm/index.mjs'; import floor from 'https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@esm/index.mjs'; -import untilEach from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-until-each@v0.2.0-esm/index.mjs'; +import untilEach from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-until-each@esm/index.mjs'; function predicate( value ) { return ( value !== value ); From 65bc6fdf4f4f4251d0de923bf47314f3014ad20f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 24 Feb 2024 15:58:18 +0000 Subject: [PATCH 084/135] 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 846d968..42f57a7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,13 +56,13 @@ function untilEach( collection, predicate, fcn, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); + throw new TypeError( format( '1YDAh', collection ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '1YD2H', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '1YD3N', fcn ) ); } len = collection.length; i = 0; diff --git a/package.json b/package.json index 79fa5b4..dc39078 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-collection": "^0.2.1", "@stdlib/assert-is-function": "^0.2.1", - "@stdlib/string-format": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1", "@stdlib/types": "^0.3.2" }, "devDependencies": { From 6c2cee72d4abf51e8cf1b37e3e952dda1df3a8e8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 24 Feb 2024 17:35:25 +0000 Subject: [PATCH 085/135] Remove files --- index.d.ts | 142 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6324 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 355b4df..0000000 --- a/index.d.ts +++ /dev/null @@ -1,142 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Checks whether an element in a collection passes a test. -* -* @returns boolean indicating whether an element in a collection passes a test -*/ -type NullaryPredicate = () => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @returns boolean indicating whether an element in a collection passes a test -*/ -type UnaryPredicate = ( value: T ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @returns boolean indicating whether an element in a collection passes a test -*/ -type BinaryPredicate = ( value: T, index: number ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type TernaryPredicate = ( value: T, index: number, collection: Collection ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Predicate = NullaryPredicate | UnaryPredicate | BinaryPredicate | TernaryPredicate; - -/** -* Function invoked for each collection element until test condition is true. -*/ -type Nullary = ( this: U ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -*/ -type Unary = ( this: U, value: T ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -*/ -type Binary = ( this: U, value: T, index: number ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Ternary = ( this: U, value: T, index: number, collection: Collection ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Until a test condition is true, invokes a function once for each element in a collection. -* -* ## Notes -* -* - When invoked, both the predicate function and the function to apply are provided three arguments: -* -* - `value`: collection value -* - `index`: collection index -* - `collection`: the input collection -* -* @param collection - input collection -* @param predicate - function which indicates whether to stop iterating over a collection -* @param fcn - function to invoke -* @param thisArg - execution context for the applied function -* @returns input collection -* -* @example -* function predicate( v, key, collection ) { -* return ( v !== v ); -* } -* -* function log( v, key, collection ) { -* console.log( '%s: %d', key, v ); -* } -* -* var arr = [ 1, 2, 3, 4, NaN, 5 ]; -* -* untilEach( arr, predicate, log ); -*/ -declare function untilEach( collection: Collection, predicate: Predicate, fcn: Callback, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = untilEach; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 52a0310..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 t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function n(n,s,i,o){var a,m;if(!t(n))throw new TypeError(r("invalid argument. First argument must be a collection. Value: `%s`.",n));if(!e(s))throw new TypeError(r("invalid argument. Second argument must be a function. Value: `%s`.",s));if(!e(i))throw new TypeError(r("invalid argument. Third argument must be a function. Value: `%s`.",i));for(a=n.length,m=0;m - - - - - - Rollup Visualizer - - - -
- - - - - From 6354a7d45db6464c7753321a8e6929f834432b3b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 24 Feb 2024 17:36:50 +0000 Subject: [PATCH 086/135] 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 | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 89 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 47 - docs/types/test.ts | 89 - examples/index.js | 53 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 83 - package.json | 61 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 350 -- 42 files changed, 4868 insertions(+), 4117 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 038a13c..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/utils/until-each) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 4eecda2..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/utils/until-each) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 aa2a9b4..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: '35 11 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 9106b5d..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -295,7 +286,7 @@ untilEach( arr, predicate, log ); ## 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]. @@ -366,9 +357,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right +[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right/tree/esm -[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each +[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each/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 754724d..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var untilEach = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var sum; - var i; - - function predicate( v ) { - return isnan( v ); - } - - function fcn( v ) { - sum += v; - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - untilEach( arr, predicate, fcn ); - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::loop', function benchmark( b ) { - var sum; - var arr; - var i; - var j; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - j = 0; - while ( j < arr.length ) { - if ( isnan( arr[ j ] ) ) { - break; - } - sum += arr[ j ]; - j += 1; - } - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 5ae3876..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/utils/until-each" -%% click B href "https://github.com/stdlib-js/utils-until-each/tree/main" -%% click C href "https://github.com/stdlib-js/utils-until-each/tree/production" -%% click D href "https://github.com/stdlib-js/utils-until-each/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-until-each/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-until-each/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/until-each -[production-url]: https://github.com/stdlib-js/utils-until-each/tree/production -[deno-url]: https://github.com/stdlib-js/utils-until-each/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-until-each/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-until-each/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-until-each/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-until-each/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-until-each/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 4378886..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import untilEach from '../docs/types/index'; -export = untilEach; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 52eaf73..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var g=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var m=g(function(E,s){ -var h=require('@stdlib/assert-is-collection/dist'),n=require('@stdlib/assert-is-function/dist'),i=require('@stdlib/error-tools-fmtprodmsg/dist');function w(r,e,a,v){var t,u;if(!h(r))throw new TypeError(i('1YDAh',r));if(!n(e))throw new TypeError(i('1YD2H',e));if(!n(a))throw new TypeError(i('1YD3N',a));for(t=r.length,u=0;u function predicate( v ) { return v !== v; }; - > function logger( v, i ) { console.log( '%s: %d', i, v ); }; - > var arr = [ 1, 2, 3, 4, NaN, 5 ]; - > {{alias}}( arr, predicate, logger ) - 0: 1 - 1: 2 - 2: 3 - 3: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4833283..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,89 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 untilEach = require( './index' ); - -/** -* Test function. -* -* @param v - value -* @param index - index -*/ -function fcn( v: number, index: number ): void { - if ( v !== v ) { - throw new Error( 'beep' ); - } - if ( index !== index ) { - throw new Error( 'beep' ); - } -} - -/** -* Test function. -* -* @param v - value -* @returns result -*/ -function isnan( v: number ): boolean { - return ( v !== v ); -} - - -// TESTS // - -// The function returns the input collection... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, fcn ); // $ExpectType Collection - untilEach( [ -1, 1, 2 ], isnan, fcn, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - untilEach( 2, isnan, fcn ); // $ExpectError - untilEach( false, isnan, fcn ); // $ExpectError - untilEach( true, isnan, fcn ); // $ExpectError - untilEach( {}, isnan, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], 2, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], false, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], true, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], 'abc', fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], {}, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], [], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, 2 ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, false ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, true ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, 'abc' ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, {} ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - untilEach(); // $ExpectError - untilEach( [ 1, 2, 3 ] ); // $ExpectError - untilEach( [ 1, 2, 3 ], isnan ); // $ExpectError - untilEach( [ 1, 2, 3 ], isnan, fcn, {}, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index c41d90c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isEven = require( '@stdlib/assert-is-even' ).isPrimitive; -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var untilEach = require( './../lib' ); - -function predicate( value ) { - return ( value !== value ); -} - -function log( value, index, collection ) { - console.log( '%s: %d', index, value ); - if ( isEven( index ) ) { - collection.shift(); - } else { - collection.push( index+1 ); - } -} - -var arr; -var j; -var i; - -arr = new Array( 100 ); -j = floor( randu()*arr.length ); -for ( i = 0; i < arr.length; i++ ) { - if ( i === j ) { - arr[ i ] = NaN; - } else { - arr[ i ] = i; - } -} - -untilEach( arr, predicate, log ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 19fe169..355b4df 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..999b5f9 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function s(s,o,i,n){var d,l;if(!r(s))throw new TypeError(e("1YDAh",s));if(!t(o))throw new TypeError(e("1YD2H",o));if(!t(i))throw new TypeError(e("1YD3N",i));for(d=s.length,l=0;l=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..33609c1 --- /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 70a1888..0000000 --- a/test/test.js +++ /dev/null @@ -1,350 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var untilEach = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof untilEach, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {}, - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( value, noop, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a predicate function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a function to invoke', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], noop, value ); - }; - } -}); - -tape( 'if provided an empty collection, the function never invokes a provided function', function test( t ) { - var arr = []; - - function predicate() { - t.fail( 'should not be invoked' ); - } - - function foo() { - t.fail( 'should not be invoked' ); - } - - untilEach( arr, predicate, foo ); - - t.deepEqual( arr, [], 'expected result' ); - t.end(); -}); - -tape( 'the function returns the input collection', function test( t ) { - var arr; - var out; - - function predicate() { - t.pass( 'invoked predicated function' ); - return false; - } - - function foo() { - t.pass( 'invoked provided function' ); - } - - arr = [ 1, 2, 3 ]; - - out = untilEach( arr, predicate, foo ); - - t.strictEqual( out, arr, 'returns input collection' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array)', function test( t ) { - var arr; - var out; - - arr = [ 1, 2, NaN, 3 ]; - out = [ 0, 0, 0, 0 ]; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - untilEach( arr, predicate, copy ); - - t.deepEqual( out, [ 1, 2, 0, 0 ], 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array-like object)', function test( t ) { - var expected; - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = { - 'length': 4, - '0': 1, - '1': 2, - '2': NaN, - '3': 3 - }; - out = { - 'length': 4, - '0': 0, - '1': 0, - '2': 0, - '3': 0 - }; - - untilEach( arr, predicate, copy ); - - expected = { - 'length': 4, - '0': 1, - '1': 2, - '2': 0, - '3': 0 - }; - - t.deepEqual( out, expected, 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (typed array)', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = new Float64Array( [ 1.0, 2.0, NaN, 3.0 ] ); - out = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - untilEach( arr, predicate, copy ); - - t.strictEqual( out[ 0 ], 1.0, 'expected result' ); - t.strictEqual( out[ 1 ], 2.0, 'expected result' ); - t.strictEqual( out[ 2 ], 0.0, 'expected result' ); - t.strictEqual( out[ 3 ], 0.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx; - var arr; - - function predicate( value ) { - return ( value !== value ); - } - - function sum( value ) { - /* eslint-disable no-invalid-this */ - this.sum += value; - this.count += 1; - } - - ctx = { - 'sum': 0, - 'count': 0 - }; - arr = [ 1.0, 2.0, 3.0 ]; - - untilEach( arr, predicate, sum, ctx ); - - t.strictEqual( ctx.sum/ctx.count, 2.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function provides basic support for dynamic arrays', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index, collection ) { - out.push( value ); - if ( index === collection.length-1 && collection.length < 10 ) { - collection.push( index+2 ); - } - } - - arr = [ 1, 2, 3 ]; - out = []; - - untilEach( arr, predicate, copy ); - - t.deepEqual( arr, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.deepEqual( out, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.end(); -}); - -tape( 'the function does not skip empty elements', function test( t ) { - var expected; - var arr; - - function predicate( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - return false; - } - - function verify( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - } - - arr = [ 1, , , 4 ]; // eslint-disable-line no-sparse-arrays - expected = [ 1, void 0, void 0, 4 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); - -tape( 'the function invokes the predicate function and the function to apply with three arguments: value, index, collection', function test( t ) { - var indices; - var values; - var arr; - - function predicate( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - return false; - } - - function verify( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - } - - arr = [ 1, 2, 3, 4 ]; - values = [ 1, 2, 3, 4 ]; - indices = [ 0, 1, 2, 3 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); From 76aa529d0f291c6dbf46992a34b3110e11acc360 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 24 Feb 2024 18:31:11 +0000 Subject: [PATCH 087/135] 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 aac3db2..4ca6b96 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import untilEach from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-until-each@esm/index.mjs'; +import untilEach from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-until-each@v0.2.1-esm/index.mjs'; ``` #### untilEach( collection, predicate, fcn\[, thisArg ] ) @@ -214,7 +214,7 @@ var mean = context.sum / context.count; var isEven = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-even' ).isPrimitive; import randu from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-randu@esm/index.mjs'; import floor from 'https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@esm/index.mjs'; -import untilEach from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-until-each@esm/index.mjs'; +import untilEach from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-until-each@v0.2.1-esm/index.mjs'; function predicate( value ) { return ( value !== value ); From 51dc688b54d7c23d5034ed9966aec2a82308621d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 24 Feb 2024 18:31:12 +0000 Subject: [PATCH 088/135] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4ca6b96..8f5b9fd 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ limitations under the License. ## Usage +```javascript +import untilEach from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-until-each@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/utils-until-each/tags). For example, + ```javascript import untilEach from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-until-each@v0.2.1-esm/index.mjs'; ``` @@ -214,7 +219,7 @@ var mean = context.sum / context.count; var isEven = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-even' ).isPrimitive; import randu from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-randu@esm/index.mjs'; import floor from 'https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@esm/index.mjs'; -import untilEach from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-until-each@v0.2.1-esm/index.mjs'; +import untilEach from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-until-each@esm/index.mjs'; function predicate( value ) { return ( value !== value ); From 39faada7cb82fc75b187ecb6d0094138cf4881bf Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 04:16:45 +0000 Subject: [PATCH 089/135] 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 846d968..42f57a7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,13 +56,13 @@ function untilEach( collection, predicate, fcn, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); + throw new TypeError( format( '1YDAh', collection ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '1YD2H', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '1YD3N', fcn ) ); } len = collection.length; i = 0; diff --git a/package.json b/package.json index 2770037..72d4195 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-collection": "^0.2.1", "@stdlib/assert-is-function": "^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 e01b3f351dce49101eb014603855c9a6dcd0943e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 08:17:24 +0000 Subject: [PATCH 090/135] Remove files --- index.d.ts | 142 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4989 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 355b4df..0000000 --- a/index.d.ts +++ /dev/null @@ -1,142 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Checks whether an element in a collection passes a test. -* -* @returns boolean indicating whether an element in a collection passes a test -*/ -type NullaryPredicate = () => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @returns boolean indicating whether an element in a collection passes a test -*/ -type UnaryPredicate = ( value: T ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @returns boolean indicating whether an element in a collection passes a test -*/ -type BinaryPredicate = ( value: T, index: number ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type TernaryPredicate = ( value: T, index: number, collection: Collection ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Predicate = NullaryPredicate | UnaryPredicate | BinaryPredicate | TernaryPredicate; - -/** -* Function invoked for each collection element until test condition is true. -*/ -type Nullary = ( this: U ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -*/ -type Unary = ( this: U, value: T ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -*/ -type Binary = ( this: U, value: T, index: number ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Ternary = ( this: U, value: T, index: number, collection: Collection ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Until a test condition is true, invokes a function once for each element in a collection. -* -* ## Notes -* -* - When invoked, both the predicate function and the function to apply are provided three arguments: -* -* - `value`: collection value -* - `index`: collection index -* - `collection`: the input collection -* -* @param collection - input collection -* @param predicate - function which indicates whether to stop iterating over a collection -* @param fcn - function to invoke -* @param thisArg - execution context for the applied function -* @returns input collection -* -* @example -* function predicate( v, key, collection ) { -* return ( v !== v ); -* } -* -* function log( v, key, collection ) { -* console.log( '%s: %d', key, v ); -* } -* -* var arr = [ 1, 2, 3, 4, NaN, 5 ]; -* -* untilEach( arr, predicate, log ); -*/ -declare function untilEach( collection: Collection, predicate: Predicate, fcn: Callback, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = untilEach; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 999b5f9..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function s(s,o,i,n){var d,l;if(!r(s))throw new TypeError(e("1YDAh",s));if(!t(o))throw new TypeError(e("1YD2H",o));if(!t(i))throw new TypeError(e("1YD3N",i));for(d=s.length,l=0;l - - - - - - Rollup Visualizer - - - -
- - - - - From 993e5af03a1b64ffd73aab8d68f0ae9f1b130d41 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 08:17:37 +0000 Subject: [PATCH 091/135] 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 | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 89 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 47 - docs/types/test.ts | 89 - examples/index.js | 53 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 83 - package.json | 62 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 350 -- 43 files changed, 4868 insertions(+), 4120 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 6f471c1..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-03-01T03:06:09.728Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 038a13c..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/utils/until-each) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 4eecda2..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/utils/until-each) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 aa2a9b4..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: '35 11 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 9106b5d..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -295,7 +286,7 @@ untilEach( arr, predicate, log ); ## 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]. @@ -366,9 +357,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right +[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right/tree/esm -[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each +[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each/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 754724d..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var untilEach = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var sum; - var i; - - function predicate( v ) { - return isnan( v ); - } - - function fcn( v ) { - sum += v; - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - untilEach( arr, predicate, fcn ); - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::loop', function benchmark( b ) { - var sum; - var arr; - var i; - var j; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - j = 0; - while ( j < arr.length ) { - if ( isnan( arr[ j ] ) ) { - break; - } - sum += arr[ j ]; - j += 1; - } - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 5ae3876..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/utils/until-each" -%% click B href "https://github.com/stdlib-js/utils-until-each/tree/main" -%% click C href "https://github.com/stdlib-js/utils-until-each/tree/production" -%% click D href "https://github.com/stdlib-js/utils-until-each/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-until-each/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-until-each/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/until-each -[production-url]: https://github.com/stdlib-js/utils-until-each/tree/production -[deno-url]: https://github.com/stdlib-js/utils-until-each/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-until-each/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-until-each/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-until-each/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-until-each/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-until-each/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 4378886..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import untilEach from '../docs/types/index'; -export = untilEach; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 52eaf73..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var g=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var m=g(function(E,s){ -var h=require('@stdlib/assert-is-collection/dist'),n=require('@stdlib/assert-is-function/dist'),i=require('@stdlib/error-tools-fmtprodmsg/dist');function w(r,e,a,v){var t,u;if(!h(r))throw new TypeError(i('1YDAh',r));if(!n(e))throw new TypeError(i('1YD2H',e));if(!n(a))throw new TypeError(i('1YD3N',a));for(t=r.length,u=0;u function predicate( v ) { return v !== v; }; - > function logger( v, i ) { console.log( '%s: %d', i, v ); }; - > var arr = [ 1, 2, 3, 4, NaN, 5 ]; - > {{alias}}( arr, predicate, logger ) - 0: 1 - 1: 2 - 2: 3 - 3: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4833283..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,89 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 untilEach = require( './index' ); - -/** -* Test function. -* -* @param v - value -* @param index - index -*/ -function fcn( v: number, index: number ): void { - if ( v !== v ) { - throw new Error( 'beep' ); - } - if ( index !== index ) { - throw new Error( 'beep' ); - } -} - -/** -* Test function. -* -* @param v - value -* @returns result -*/ -function isnan( v: number ): boolean { - return ( v !== v ); -} - - -// TESTS // - -// The function returns the input collection... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, fcn ); // $ExpectType Collection - untilEach( [ -1, 1, 2 ], isnan, fcn, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - untilEach( 2, isnan, fcn ); // $ExpectError - untilEach( false, isnan, fcn ); // $ExpectError - untilEach( true, isnan, fcn ); // $ExpectError - untilEach( {}, isnan, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], 2, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], false, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], true, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], 'abc', fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], {}, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], [], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, 2 ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, false ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, true ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, 'abc' ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, {} ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - untilEach(); // $ExpectError - untilEach( [ 1, 2, 3 ] ); // $ExpectError - untilEach( [ 1, 2, 3 ], isnan ); // $ExpectError - untilEach( [ 1, 2, 3 ], isnan, fcn, {}, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index c41d90c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isEven = require( '@stdlib/assert-is-even' ).isPrimitive; -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var untilEach = require( './../lib' ); - -function predicate( value ) { - return ( value !== value ); -} - -function log( value, index, collection ) { - console.log( '%s: %d', index, value ); - if ( isEven( index ) ) { - collection.shift(); - } else { - collection.push( index+1 ); - } -} - -var arr; -var j; -var i; - -arr = new Array( 100 ); -j = floor( randu()*arr.length ); -for ( i = 0; i < arr.length; i++ ) { - if ( i === j ) { - arr[ i ] = NaN; - } else { - arr[ i ] = i; - } -} - -untilEach( arr, predicate, log ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 19fe169..355b4df 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..45e7cb8 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function s(s,o,i,n){var d,l;if(!r(s))throw new TypeError(e("1YDAh",s));if(!t(o))throw new TypeError(e("1YD2H",o));if(!t(i))throw new TypeError(e("1YD3N",i));for(d=s.length,l=0;l=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..0c9267b --- /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 70a1888..0000000 --- a/test/test.js +++ /dev/null @@ -1,350 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var untilEach = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof untilEach, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {}, - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( value, noop, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a predicate function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a function to invoke', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], noop, value ); - }; - } -}); - -tape( 'if provided an empty collection, the function never invokes a provided function', function test( t ) { - var arr = []; - - function predicate() { - t.fail( 'should not be invoked' ); - } - - function foo() { - t.fail( 'should not be invoked' ); - } - - untilEach( arr, predicate, foo ); - - t.deepEqual( arr, [], 'expected result' ); - t.end(); -}); - -tape( 'the function returns the input collection', function test( t ) { - var arr; - var out; - - function predicate() { - t.pass( 'invoked predicated function' ); - return false; - } - - function foo() { - t.pass( 'invoked provided function' ); - } - - arr = [ 1, 2, 3 ]; - - out = untilEach( arr, predicate, foo ); - - t.strictEqual( out, arr, 'returns input collection' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array)', function test( t ) { - var arr; - var out; - - arr = [ 1, 2, NaN, 3 ]; - out = [ 0, 0, 0, 0 ]; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - untilEach( arr, predicate, copy ); - - t.deepEqual( out, [ 1, 2, 0, 0 ], 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array-like object)', function test( t ) { - var expected; - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = { - 'length': 4, - '0': 1, - '1': 2, - '2': NaN, - '3': 3 - }; - out = { - 'length': 4, - '0': 0, - '1': 0, - '2': 0, - '3': 0 - }; - - untilEach( arr, predicate, copy ); - - expected = { - 'length': 4, - '0': 1, - '1': 2, - '2': 0, - '3': 0 - }; - - t.deepEqual( out, expected, 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (typed array)', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = new Float64Array( [ 1.0, 2.0, NaN, 3.0 ] ); - out = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - untilEach( arr, predicate, copy ); - - t.strictEqual( out[ 0 ], 1.0, 'expected result' ); - t.strictEqual( out[ 1 ], 2.0, 'expected result' ); - t.strictEqual( out[ 2 ], 0.0, 'expected result' ); - t.strictEqual( out[ 3 ], 0.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx; - var arr; - - function predicate( value ) { - return ( value !== value ); - } - - function sum( value ) { - /* eslint-disable no-invalid-this */ - this.sum += value; - this.count += 1; - } - - ctx = { - 'sum': 0, - 'count': 0 - }; - arr = [ 1.0, 2.0, 3.0 ]; - - untilEach( arr, predicate, sum, ctx ); - - t.strictEqual( ctx.sum/ctx.count, 2.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function provides basic support for dynamic arrays', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index, collection ) { - out.push( value ); - if ( index === collection.length-1 && collection.length < 10 ) { - collection.push( index+2 ); - } - } - - arr = [ 1, 2, 3 ]; - out = []; - - untilEach( arr, predicate, copy ); - - t.deepEqual( arr, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.deepEqual( out, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.end(); -}); - -tape( 'the function does not skip empty elements', function test( t ) { - var expected; - var arr; - - function predicate( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - return false; - } - - function verify( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - } - - arr = [ 1, , , 4 ]; // eslint-disable-line no-sparse-arrays - expected = [ 1, void 0, void 0, 4 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); - -tape( 'the function invokes the predicate function and the function to apply with three arguments: value, index, collection', function test( t ) { - var indices; - var values; - var arr; - - function predicate( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - return false; - } - - function verify( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - } - - arr = [ 1, 2, 3, 4 ]; - values = [ 1, 2, 3, 4 ]; - indices = [ 0, 1, 2, 3 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); From 980479febd231a1b729d6958c06b6147d54c8581 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 03:47:03 +0000 Subject: [PATCH 092/135] 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 846d968..42f57a7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,13 +56,13 @@ function untilEach( collection, predicate, fcn, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); + throw new TypeError( format( '1YDAh', collection ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '1YD2H', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '1YD3N', fcn ) ); } len = collection.length; i = 0; diff --git a/package.json b/package.json index 98fadc6..ccaf4b3 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-collection": "^0.2.1", "@stdlib/assert-is-function": "^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 7cad13aaf988879dbfcdde585251ceb60ad7f50b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 08:01:48 +0000 Subject: [PATCH 093/135] Remove files --- index.d.ts | 142 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4989 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 355b4df..0000000 --- a/index.d.ts +++ /dev/null @@ -1,142 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Checks whether an element in a collection passes a test. -* -* @returns boolean indicating whether an element in a collection passes a test -*/ -type NullaryPredicate = () => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @returns boolean indicating whether an element in a collection passes a test -*/ -type UnaryPredicate = ( value: T ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @returns boolean indicating whether an element in a collection passes a test -*/ -type BinaryPredicate = ( value: T, index: number ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type TernaryPredicate = ( value: T, index: number, collection: Collection ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Predicate = NullaryPredicate | UnaryPredicate | BinaryPredicate | TernaryPredicate; - -/** -* Function invoked for each collection element until test condition is true. -*/ -type Nullary = ( this: U ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -*/ -type Unary = ( this: U, value: T ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -*/ -type Binary = ( this: U, value: T, index: number ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Ternary = ( this: U, value: T, index: number, collection: Collection ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Until a test condition is true, invokes a function once for each element in a collection. -* -* ## Notes -* -* - When invoked, both the predicate function and the function to apply are provided three arguments: -* -* - `value`: collection value -* - `index`: collection index -* - `collection`: the input collection -* -* @param collection - input collection -* @param predicate - function which indicates whether to stop iterating over a collection -* @param fcn - function to invoke -* @param thisArg - execution context for the applied function -* @returns input collection -* -* @example -* function predicate( v, key, collection ) { -* return ( v !== v ); -* } -* -* function log( v, key, collection ) { -* console.log( '%s: %d', key, v ); -* } -* -* var arr = [ 1, 2, 3, 4, NaN, 5 ]; -* -* untilEach( arr, predicate, log ); -*/ -declare function untilEach( collection: Collection, predicate: Predicate, fcn: Callback, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = untilEach; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 45e7cb8..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function s(s,o,i,n){var d,l;if(!r(s))throw new TypeError(e("1YDAh",s));if(!t(o))throw new TypeError(e("1YD2H",o));if(!t(i))throw new TypeError(e("1YD3N",i));for(d=s.length,l=0;l - - - - - - Rollup Visualizer - - - -
- - - - - From 58453253dd0b66025c5f764e7254cf7c42153eb3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 08:02:01 +0000 Subject: [PATCH 094/135] 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 | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 89 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 47 - docs/types/test.ts | 89 - examples/index.js | 53 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 83 - package.json | 62 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 350 -- 43 files changed, 4868 insertions(+), 4123 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 3a67b88..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-04-01T02:32:18.443Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 038a13c..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/utils/until-each) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 4eecda2..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/utils/until-each) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 aa2a9b4..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: '35 11 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index ec90164..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -295,7 +286,7 @@ untilEach( arr, predicate, log ); ## 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]. @@ -366,9 +357,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right +[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right/tree/esm -[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each +[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each/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 754724d..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var untilEach = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var sum; - var i; - - function predicate( v ) { - return isnan( v ); - } - - function fcn( v ) { - sum += v; - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - untilEach( arr, predicate, fcn ); - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::loop', function benchmark( b ) { - var sum; - var arr; - var i; - var j; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - j = 0; - while ( j < arr.length ) { - if ( isnan( arr[ j ] ) ) { - break; - } - sum += arr[ j ]; - j += 1; - } - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 5ae3876..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/utils/until-each" -%% click B href "https://github.com/stdlib-js/utils-until-each/tree/main" -%% click C href "https://github.com/stdlib-js/utils-until-each/tree/production" -%% click D href "https://github.com/stdlib-js/utils-until-each/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-until-each/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-until-each/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/until-each -[production-url]: https://github.com/stdlib-js/utils-until-each/tree/production -[deno-url]: https://github.com/stdlib-js/utils-until-each/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-until-each/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-until-each/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-until-each/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-until-each/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-until-each/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 4378886..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import untilEach from '../docs/types/index'; -export = untilEach; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 52eaf73..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var g=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var m=g(function(E,s){ -var h=require('@stdlib/assert-is-collection/dist'),n=require('@stdlib/assert-is-function/dist'),i=require('@stdlib/error-tools-fmtprodmsg/dist');function w(r,e,a,v){var t,u;if(!h(r))throw new TypeError(i('1YDAh',r));if(!n(e))throw new TypeError(i('1YD2H',e));if(!n(a))throw new TypeError(i('1YD3N',a));for(t=r.length,u=0;u function predicate( v ) { return v !== v; }; - > function logger( v, i ) { console.log( '%s: %d', i, v ); }; - > var arr = [ 1, 2, 3, 4, NaN, 5 ]; - > {{alias}}( arr, predicate, logger ) - 0: 1 - 1: 2 - 2: 3 - 3: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4833283..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,89 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 untilEach = require( './index' ); - -/** -* Test function. -* -* @param v - value -* @param index - index -*/ -function fcn( v: number, index: number ): void { - if ( v !== v ) { - throw new Error( 'beep' ); - } - if ( index !== index ) { - throw new Error( 'beep' ); - } -} - -/** -* Test function. -* -* @param v - value -* @returns result -*/ -function isnan( v: number ): boolean { - return ( v !== v ); -} - - -// TESTS // - -// The function returns the input collection... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, fcn ); // $ExpectType Collection - untilEach( [ -1, 1, 2 ], isnan, fcn, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - untilEach( 2, isnan, fcn ); // $ExpectError - untilEach( false, isnan, fcn ); // $ExpectError - untilEach( true, isnan, fcn ); // $ExpectError - untilEach( {}, isnan, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], 2, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], false, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], true, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], 'abc', fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], {}, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], [], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, 2 ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, false ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, true ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, 'abc' ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, {} ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - untilEach(); // $ExpectError - untilEach( [ 1, 2, 3 ] ); // $ExpectError - untilEach( [ 1, 2, 3 ], isnan ); // $ExpectError - untilEach( [ 1, 2, 3 ], isnan, fcn, {}, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index c41d90c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isEven = require( '@stdlib/assert-is-even' ).isPrimitive; -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var untilEach = require( './../lib' ); - -function predicate( value ) { - return ( value !== value ); -} - -function log( value, index, collection ) { - console.log( '%s: %d', index, value ); - if ( isEven( index ) ) { - collection.shift(); - } else { - collection.push( index+1 ); - } -} - -var arr; -var j; -var i; - -arr = new Array( 100 ); -j = floor( randu()*arr.length ); -for ( i = 0; i < arr.length; i++ ) { - if ( i === j ) { - arr[ i ] = NaN; - } else { - arr[ i ] = i; - } -} - -untilEach( arr, predicate, log ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 19fe169..355b4df 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..45e7cb8 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function s(s,o,i,n){var d,l;if(!r(s))throw new TypeError(e("1YDAh",s));if(!t(o))throw new TypeError(e("1YD2H",o));if(!t(i))throw new TypeError(e("1YD3N",i));for(d=s.length,l=0;l=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..0c9267b --- /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 70a1888..0000000 --- a/test/test.js +++ /dev/null @@ -1,350 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var untilEach = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof untilEach, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {}, - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( value, noop, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a predicate function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a function to invoke', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], noop, value ); - }; - } -}); - -tape( 'if provided an empty collection, the function never invokes a provided function', function test( t ) { - var arr = []; - - function predicate() { - t.fail( 'should not be invoked' ); - } - - function foo() { - t.fail( 'should not be invoked' ); - } - - untilEach( arr, predicate, foo ); - - t.deepEqual( arr, [], 'expected result' ); - t.end(); -}); - -tape( 'the function returns the input collection', function test( t ) { - var arr; - var out; - - function predicate() { - t.pass( 'invoked predicated function' ); - return false; - } - - function foo() { - t.pass( 'invoked provided function' ); - } - - arr = [ 1, 2, 3 ]; - - out = untilEach( arr, predicate, foo ); - - t.strictEqual( out, arr, 'returns input collection' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array)', function test( t ) { - var arr; - var out; - - arr = [ 1, 2, NaN, 3 ]; - out = [ 0, 0, 0, 0 ]; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - untilEach( arr, predicate, copy ); - - t.deepEqual( out, [ 1, 2, 0, 0 ], 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array-like object)', function test( t ) { - var expected; - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = { - 'length': 4, - '0': 1, - '1': 2, - '2': NaN, - '3': 3 - }; - out = { - 'length': 4, - '0': 0, - '1': 0, - '2': 0, - '3': 0 - }; - - untilEach( arr, predicate, copy ); - - expected = { - 'length': 4, - '0': 1, - '1': 2, - '2': 0, - '3': 0 - }; - - t.deepEqual( out, expected, 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (typed array)', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = new Float64Array( [ 1.0, 2.0, NaN, 3.0 ] ); - out = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - untilEach( arr, predicate, copy ); - - t.strictEqual( out[ 0 ], 1.0, 'expected result' ); - t.strictEqual( out[ 1 ], 2.0, 'expected result' ); - t.strictEqual( out[ 2 ], 0.0, 'expected result' ); - t.strictEqual( out[ 3 ], 0.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx; - var arr; - - function predicate( value ) { - return ( value !== value ); - } - - function sum( value ) { - /* eslint-disable no-invalid-this */ - this.sum += value; - this.count += 1; - } - - ctx = { - 'sum': 0, - 'count': 0 - }; - arr = [ 1.0, 2.0, 3.0 ]; - - untilEach( arr, predicate, sum, ctx ); - - t.strictEqual( ctx.sum/ctx.count, 2.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function provides basic support for dynamic arrays', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index, collection ) { - out.push( value ); - if ( index === collection.length-1 && collection.length < 10 ) { - collection.push( index+2 ); - } - } - - arr = [ 1, 2, 3 ]; - out = []; - - untilEach( arr, predicate, copy ); - - t.deepEqual( arr, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.deepEqual( out, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.end(); -}); - -tape( 'the function does not skip empty elements', function test( t ) { - var expected; - var arr; - - function predicate( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - return false; - } - - function verify( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - } - - arr = [ 1, , , 4 ]; // eslint-disable-line no-sparse-arrays - expected = [ 1, void 0, void 0, 4 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); - -tape( 'the function invokes the predicate function and the function to apply with three arguments: value, index, collection', function test( t ) { - var indices; - var values; - var arr; - - function predicate( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - return false; - } - - function verify( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - } - - arr = [ 1, 2, 3, 4 ]; - values = [ 1, 2, 3, 4 ]; - indices = [ 0, 1, 2, 3 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); From 5335030994f4890b850b2f4a408c74881d31ce47 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 11 Apr 2024 23:56:31 +0000 Subject: [PATCH 095/135] 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 846d968..42f57a7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,13 +56,13 @@ function untilEach( collection, predicate, fcn, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); + throw new TypeError( format( '1YDAh', collection ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '1YD2H', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '1YD3N', fcn ) ); } len = collection.length; i = 0; diff --git a/package.json b/package.json index 98fadc6..ccaf4b3 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-collection": "^0.2.1", "@stdlib/assert-is-function": "^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 8f4e958e82f1725d98e3f9e2eb8c7025cafad2c8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 04:52:36 +0000 Subject: [PATCH 096/135] Remove files --- index.d.ts | 142 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4989 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 355b4df..0000000 --- a/index.d.ts +++ /dev/null @@ -1,142 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Checks whether an element in a collection passes a test. -* -* @returns boolean indicating whether an element in a collection passes a test -*/ -type NullaryPredicate = () => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @returns boolean indicating whether an element in a collection passes a test -*/ -type UnaryPredicate = ( value: T ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @returns boolean indicating whether an element in a collection passes a test -*/ -type BinaryPredicate = ( value: T, index: number ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type TernaryPredicate = ( value: T, index: number, collection: Collection ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Predicate = NullaryPredicate | UnaryPredicate | BinaryPredicate | TernaryPredicate; - -/** -* Function invoked for each collection element until test condition is true. -*/ -type Nullary = ( this: U ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -*/ -type Unary = ( this: U, value: T ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -*/ -type Binary = ( this: U, value: T, index: number ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Ternary = ( this: U, value: T, index: number, collection: Collection ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Until a test condition is true, invokes a function once for each element in a collection. -* -* ## Notes -* -* - When invoked, both the predicate function and the function to apply are provided three arguments: -* -* - `value`: collection value -* - `index`: collection index -* - `collection`: the input collection -* -* @param collection - input collection -* @param predicate - function which indicates whether to stop iterating over a collection -* @param fcn - function to invoke -* @param thisArg - execution context for the applied function -* @returns input collection -* -* @example -* function predicate( v, key, collection ) { -* return ( v !== v ); -* } -* -* function log( v, key, collection ) { -* console.log( '%s: %d', key, v ); -* } -* -* var arr = [ 1, 2, 3, 4, NaN, 5 ]; -* -* untilEach( arr, predicate, log ); -*/ -declare function untilEach( collection: Collection, predicate: Predicate, fcn: Callback, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = untilEach; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 45e7cb8..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function s(s,o,i,n){var d,l;if(!r(s))throw new TypeError(e("1YDAh",s));if(!t(o))throw new TypeError(e("1YD2H",o));if(!t(i))throw new TypeError(e("1YD3N",i));for(d=s.length,l=0;l - - - - - - Rollup Visualizer - - - -
- - - - - From 64a8e6cb3574b8e48d98376938ce7365299f6693 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 04:52:49 +0000 Subject: [PATCH 097/135] 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 | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 89 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 47 - docs/types/test.ts | 89 - examples/index.js | 53 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 83 - package.json | 62 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 350 -- 42 files changed, 4868 insertions(+), 4124 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 038a13c..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/utils/until-each) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 4eecda2..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/utils/until-each) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 aa2a9b4..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: '35 11 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index ec90164..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -295,7 +286,7 @@ untilEach( arr, predicate, log ); ## 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]. @@ -366,9 +357,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right +[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right/tree/esm -[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each +[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each/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 754724d..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var untilEach = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var sum; - var i; - - function predicate( v ) { - return isnan( v ); - } - - function fcn( v ) { - sum += v; - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - untilEach( arr, predicate, fcn ); - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::loop', function benchmark( b ) { - var sum; - var arr; - var i; - var j; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - j = 0; - while ( j < arr.length ) { - if ( isnan( arr[ j ] ) ) { - break; - } - sum += arr[ j ]; - j += 1; - } - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 5ae3876..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/utils/until-each" -%% click B href "https://github.com/stdlib-js/utils-until-each/tree/main" -%% click C href "https://github.com/stdlib-js/utils-until-each/tree/production" -%% click D href "https://github.com/stdlib-js/utils-until-each/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-until-each/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-until-each/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/until-each -[production-url]: https://github.com/stdlib-js/utils-until-each/tree/production -[deno-url]: https://github.com/stdlib-js/utils-until-each/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-until-each/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-until-each/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-until-each/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-until-each/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-until-each/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 4378886..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import untilEach from '../docs/types/index'; -export = untilEach; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 52eaf73..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var g=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var m=g(function(E,s){ -var h=require('@stdlib/assert-is-collection/dist'),n=require('@stdlib/assert-is-function/dist'),i=require('@stdlib/error-tools-fmtprodmsg/dist');function w(r,e,a,v){var t,u;if(!h(r))throw new TypeError(i('1YDAh',r));if(!n(e))throw new TypeError(i('1YD2H',e));if(!n(a))throw new TypeError(i('1YD3N',a));for(t=r.length,u=0;u function predicate( v ) { return v !== v; }; - > function logger( v, i ) { console.log( '%s: %d', i, v ); }; - > var arr = [ 1, 2, 3, 4, NaN, 5 ]; - > {{alias}}( arr, predicate, logger ) - 0: 1 - 1: 2 - 2: 3 - 3: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4833283..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,89 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 untilEach = require( './index' ); - -/** -* Test function. -* -* @param v - value -* @param index - index -*/ -function fcn( v: number, index: number ): void { - if ( v !== v ) { - throw new Error( 'beep' ); - } - if ( index !== index ) { - throw new Error( 'beep' ); - } -} - -/** -* Test function. -* -* @param v - value -* @returns result -*/ -function isnan( v: number ): boolean { - return ( v !== v ); -} - - -// TESTS // - -// The function returns the input collection... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, fcn ); // $ExpectType Collection - untilEach( [ -1, 1, 2 ], isnan, fcn, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - untilEach( 2, isnan, fcn ); // $ExpectError - untilEach( false, isnan, fcn ); // $ExpectError - untilEach( true, isnan, fcn ); // $ExpectError - untilEach( {}, isnan, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], 2, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], false, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], true, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], 'abc', fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], {}, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], [], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, 2 ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, false ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, true ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, 'abc' ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, {} ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - untilEach(); // $ExpectError - untilEach( [ 1, 2, 3 ] ); // $ExpectError - untilEach( [ 1, 2, 3 ], isnan ); // $ExpectError - untilEach( [ 1, 2, 3 ], isnan, fcn, {}, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index c41d90c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isEven = require( '@stdlib/assert-is-even' ).isPrimitive; -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var untilEach = require( './../lib' ); - -function predicate( value ) { - return ( value !== value ); -} - -function log( value, index, collection ) { - console.log( '%s: %d', index, value ); - if ( isEven( index ) ) { - collection.shift(); - } else { - collection.push( index+1 ); - } -} - -var arr; -var j; -var i; - -arr = new Array( 100 ); -j = floor( randu()*arr.length ); -for ( i = 0; i < arr.length; i++ ) { - if ( i === j ) { - arr[ i ] = NaN; - } else { - arr[ i ] = i; - } -} - -untilEach( arr, predicate, log ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 19fe169..355b4df 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..45e7cb8 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function s(s,o,i,n){var d,l;if(!r(s))throw new TypeError(e("1YDAh",s));if(!t(o))throw new TypeError(e("1YD2H",o));if(!t(i))throw new TypeError(e("1YD3N",i));for(d=s.length,l=0;l=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..0c9267b --- /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 70a1888..0000000 --- a/test/test.js +++ /dev/null @@ -1,350 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var untilEach = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof untilEach, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {}, - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( value, noop, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a predicate function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a function to invoke', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], noop, value ); - }; - } -}); - -tape( 'if provided an empty collection, the function never invokes a provided function', function test( t ) { - var arr = []; - - function predicate() { - t.fail( 'should not be invoked' ); - } - - function foo() { - t.fail( 'should not be invoked' ); - } - - untilEach( arr, predicate, foo ); - - t.deepEqual( arr, [], 'expected result' ); - t.end(); -}); - -tape( 'the function returns the input collection', function test( t ) { - var arr; - var out; - - function predicate() { - t.pass( 'invoked predicated function' ); - return false; - } - - function foo() { - t.pass( 'invoked provided function' ); - } - - arr = [ 1, 2, 3 ]; - - out = untilEach( arr, predicate, foo ); - - t.strictEqual( out, arr, 'returns input collection' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array)', function test( t ) { - var arr; - var out; - - arr = [ 1, 2, NaN, 3 ]; - out = [ 0, 0, 0, 0 ]; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - untilEach( arr, predicate, copy ); - - t.deepEqual( out, [ 1, 2, 0, 0 ], 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array-like object)', function test( t ) { - var expected; - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = { - 'length': 4, - '0': 1, - '1': 2, - '2': NaN, - '3': 3 - }; - out = { - 'length': 4, - '0': 0, - '1': 0, - '2': 0, - '3': 0 - }; - - untilEach( arr, predicate, copy ); - - expected = { - 'length': 4, - '0': 1, - '1': 2, - '2': 0, - '3': 0 - }; - - t.deepEqual( out, expected, 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (typed array)', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = new Float64Array( [ 1.0, 2.0, NaN, 3.0 ] ); - out = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - untilEach( arr, predicate, copy ); - - t.strictEqual( out[ 0 ], 1.0, 'expected result' ); - t.strictEqual( out[ 1 ], 2.0, 'expected result' ); - t.strictEqual( out[ 2 ], 0.0, 'expected result' ); - t.strictEqual( out[ 3 ], 0.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx; - var arr; - - function predicate( value ) { - return ( value !== value ); - } - - function sum( value ) { - /* eslint-disable no-invalid-this */ - this.sum += value; - this.count += 1; - } - - ctx = { - 'sum': 0, - 'count': 0 - }; - arr = [ 1.0, 2.0, 3.0 ]; - - untilEach( arr, predicate, sum, ctx ); - - t.strictEqual( ctx.sum/ctx.count, 2.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function provides basic support for dynamic arrays', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index, collection ) { - out.push( value ); - if ( index === collection.length-1 && collection.length < 10 ) { - collection.push( index+2 ); - } - } - - arr = [ 1, 2, 3 ]; - out = []; - - untilEach( arr, predicate, copy ); - - t.deepEqual( arr, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.deepEqual( out, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.end(); -}); - -tape( 'the function does not skip empty elements', function test( t ) { - var expected; - var arr; - - function predicate( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - return false; - } - - function verify( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - } - - arr = [ 1, , , 4 ]; // eslint-disable-line no-sparse-arrays - expected = [ 1, void 0, void 0, 4 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); - -tape( 'the function invokes the predicate function and the function to apply with three arguments: value, index, collection', function test( t ) { - var indices; - var values; - var arr; - - function predicate( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - return false; - } - - function verify( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - } - - arr = [ 1, 2, 3, 4 ]; - values = [ 1, 2, 3, 4 ]; - indices = [ 0, 1, 2, 3 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); From 53fbf1627405108d7587a5c9d871239041cab066 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 28 Jul 2024 00:07:08 +0000 Subject: [PATCH 098/135] 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 846d968..42f57a7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,13 +56,13 @@ function untilEach( collection, predicate, fcn, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); + throw new TypeError( format( '1YDAh', collection ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '1YD2H', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '1YD3N', fcn ) ); } len = collection.length; i = 0; diff --git a/package.json b/package.json index 8660430..4c3b720 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-collection": "^0.2.1", "@stdlib/assert-is-function": "^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 d4e06fbe62338beb4893c08384d8b759147bb90c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 28 Jul 2024 00:17:17 +0000 Subject: [PATCH 099/135] Remove files --- index.d.ts | 142 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4989 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 355b4df..0000000 --- a/index.d.ts +++ /dev/null @@ -1,142 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Checks whether an element in a collection passes a test. -* -* @returns boolean indicating whether an element in a collection passes a test -*/ -type NullaryPredicate = () => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @returns boolean indicating whether an element in a collection passes a test -*/ -type UnaryPredicate = ( value: T ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @returns boolean indicating whether an element in a collection passes a test -*/ -type BinaryPredicate = ( value: T, index: number ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type TernaryPredicate = ( value: T, index: number, collection: Collection ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Predicate = NullaryPredicate | UnaryPredicate | BinaryPredicate | TernaryPredicate; - -/** -* Function invoked for each collection element until test condition is true. -*/ -type Nullary = ( this: U ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -*/ -type Unary = ( this: U, value: T ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -*/ -type Binary = ( this: U, value: T, index: number ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Ternary = ( this: U, value: T, index: number, collection: Collection ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Until a test condition is true, invokes a function once for each element in a collection. -* -* ## Notes -* -* - When invoked, both the predicate function and the function to apply are provided three arguments: -* -* - `value`: collection value -* - `index`: collection index -* - `collection`: the input collection -* -* @param collection - input collection -* @param predicate - function which indicates whether to stop iterating over a collection -* @param fcn - function to invoke -* @param thisArg - execution context for the applied function -* @returns input collection -* -* @example -* function predicate( v, key, collection ) { -* return ( v !== v ); -* } -* -* function log( v, key, collection ) { -* console.log( '%s: %d', key, v ); -* } -* -* var arr = [ 1, 2, 3, 4, NaN, 5 ]; -* -* untilEach( arr, predicate, log ); -*/ -declare function untilEach( collection: Collection, predicate: Predicate, fcn: Callback, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = untilEach; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 45e7cb8..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function s(s,o,i,n){var d,l;if(!r(s))throw new TypeError(e("1YDAh",s));if(!t(o))throw new TypeError(e("1YD2H",o));if(!t(i))throw new TypeError(e("1YD3N",i));for(d=s.length,l=0;l - - - - - - Rollup Visualizer - - - -
- - - - - From 89b03de18920893deb038cae8e03a341aafd6070 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 28 Jul 2024 00:17:33 +0000 Subject: [PATCH 100/135] 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 | 184 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 89 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 47 - docs/types/test.ts | 89 - examples/index.js | 53 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 83 - package.json | 62 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 350 -- 42 files changed, 4868 insertions(+), 4314 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 038a13c..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/utils/until-each) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 4eecda2..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/utils/until-each) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 aa2a9b4..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: '35 11 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -295,7 +286,7 @@ untilEach( arr, predicate, log ); ## 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]. @@ -366,9 +357,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right +[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right/tree/esm -[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each +[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each/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 754724d..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var untilEach = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var sum; - var i; - - function predicate( v ) { - return isnan( v ); - } - - function fcn( v ) { - sum += v; - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - untilEach( arr, predicate, fcn ); - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::loop', function benchmark( b ) { - var sum; - var arr; - var i; - var j; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - j = 0; - while ( j < arr.length ) { - if ( isnan( arr[ j ] ) ) { - break; - } - sum += arr[ j ]; - j += 1; - } - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 5ae3876..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/utils/until-each" -%% click B href "https://github.com/stdlib-js/utils-until-each/tree/main" -%% click C href "https://github.com/stdlib-js/utils-until-each/tree/production" -%% click D href "https://github.com/stdlib-js/utils-until-each/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-until-each/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-until-each/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/until-each -[production-url]: https://github.com/stdlib-js/utils-until-each/tree/production -[deno-url]: https://github.com/stdlib-js/utils-until-each/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-until-each/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-until-each/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-until-each/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-until-each/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-until-each/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 4378886..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import untilEach from '../docs/types/index'; -export = untilEach; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 52eaf73..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var g=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var m=g(function(E,s){ -var h=require('@stdlib/assert-is-collection/dist'),n=require('@stdlib/assert-is-function/dist'),i=require('@stdlib/error-tools-fmtprodmsg/dist');function w(r,e,a,v){var t,u;if(!h(r))throw new TypeError(i('1YDAh',r));if(!n(e))throw new TypeError(i('1YD2H',e));if(!n(a))throw new TypeError(i('1YD3N',a));for(t=r.length,u=0;u function predicate( v ) { return v !== v; }; - > function logger( v, i ) { console.log( '%s: %d', i, v ); }; - > var arr = [ 1, 2, 3, 4, NaN, 5 ]; - > {{alias}}( arr, predicate, logger ) - 0: 1 - 1: 2 - 2: 3 - 3: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4833283..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,89 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 untilEach = require( './index' ); - -/** -* Test function. -* -* @param v - value -* @param index - index -*/ -function fcn( v: number, index: number ): void { - if ( v !== v ) { - throw new Error( 'beep' ); - } - if ( index !== index ) { - throw new Error( 'beep' ); - } -} - -/** -* Test function. -* -* @param v - value -* @returns result -*/ -function isnan( v: number ): boolean { - return ( v !== v ); -} - - -// TESTS // - -// The function returns the input collection... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, fcn ); // $ExpectType Collection - untilEach( [ -1, 1, 2 ], isnan, fcn, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - untilEach( 2, isnan, fcn ); // $ExpectError - untilEach( false, isnan, fcn ); // $ExpectError - untilEach( true, isnan, fcn ); // $ExpectError - untilEach( {}, isnan, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], 2, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], false, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], true, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], 'abc', fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], {}, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], [], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, 2 ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, false ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, true ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, 'abc' ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, {} ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - untilEach(); // $ExpectError - untilEach( [ 1, 2, 3 ] ); // $ExpectError - untilEach( [ 1, 2, 3 ], isnan ); // $ExpectError - untilEach( [ 1, 2, 3 ], isnan, fcn, {}, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index c41d90c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isEven = require( '@stdlib/assert-is-even' ).isPrimitive; -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var untilEach = require( './../lib' ); - -function predicate( value ) { - return ( value !== value ); -} - -function log( value, index, collection ) { - console.log( '%s: %d', index, value ); - if ( isEven( index ) ) { - collection.shift(); - } else { - collection.push( index+1 ); - } -} - -var arr; -var j; -var i; - -arr = new Array( 100 ); -j = floor( randu()*arr.length ); -for ( i = 0; i < arr.length; i++ ) { - if ( i === j ) { - arr[ i ] = NaN; - } else { - arr[ i ] = i; - } -} - -untilEach( arr, predicate, log ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 19fe169..355b4df 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..10553a0 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function s(s,o,i,n){var d,l;if(!r(s))throw new TypeError(e("1YDAh",s));if(!t(o))throw new TypeError(e("1YD2H",o));if(!t(i))throw new TypeError(e("1YD3N",i));for(d=s.length,l=0;l=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b4d9451 --- /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 70a1888..0000000 --- a/test/test.js +++ /dev/null @@ -1,350 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var untilEach = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof untilEach, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {}, - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( value, noop, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a predicate function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a function to invoke', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], noop, value ); - }; - } -}); - -tape( 'if provided an empty collection, the function never invokes a provided function', function test( t ) { - var arr = []; - - function predicate() { - t.fail( 'should not be invoked' ); - } - - function foo() { - t.fail( 'should not be invoked' ); - } - - untilEach( arr, predicate, foo ); - - t.deepEqual( arr, [], 'expected result' ); - t.end(); -}); - -tape( 'the function returns the input collection', function test( t ) { - var arr; - var out; - - function predicate() { - t.pass( 'invoked predicated function' ); - return false; - } - - function foo() { - t.pass( 'invoked provided function' ); - } - - arr = [ 1, 2, 3 ]; - - out = untilEach( arr, predicate, foo ); - - t.strictEqual( out, arr, 'returns input collection' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array)', function test( t ) { - var arr; - var out; - - arr = [ 1, 2, NaN, 3 ]; - out = [ 0, 0, 0, 0 ]; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - untilEach( arr, predicate, copy ); - - t.deepEqual( out, [ 1, 2, 0, 0 ], 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array-like object)', function test( t ) { - var expected; - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = { - 'length': 4, - '0': 1, - '1': 2, - '2': NaN, - '3': 3 - }; - out = { - 'length': 4, - '0': 0, - '1': 0, - '2': 0, - '3': 0 - }; - - untilEach( arr, predicate, copy ); - - expected = { - 'length': 4, - '0': 1, - '1': 2, - '2': 0, - '3': 0 - }; - - t.deepEqual( out, expected, 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (typed array)', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = new Float64Array( [ 1.0, 2.0, NaN, 3.0 ] ); - out = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - untilEach( arr, predicate, copy ); - - t.strictEqual( out[ 0 ], 1.0, 'expected result' ); - t.strictEqual( out[ 1 ], 2.0, 'expected result' ); - t.strictEqual( out[ 2 ], 0.0, 'expected result' ); - t.strictEqual( out[ 3 ], 0.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx; - var arr; - - function predicate( value ) { - return ( value !== value ); - } - - function sum( value ) { - /* eslint-disable no-invalid-this */ - this.sum += value; - this.count += 1; - } - - ctx = { - 'sum': 0, - 'count': 0 - }; - arr = [ 1.0, 2.0, 3.0 ]; - - untilEach( arr, predicate, sum, ctx ); - - t.strictEqual( ctx.sum/ctx.count, 2.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function provides basic support for dynamic arrays', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index, collection ) { - out.push( value ); - if ( index === collection.length-1 && collection.length < 10 ) { - collection.push( index+2 ); - } - } - - arr = [ 1, 2, 3 ]; - out = []; - - untilEach( arr, predicate, copy ); - - t.deepEqual( arr, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.deepEqual( out, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.end(); -}); - -tape( 'the function does not skip empty elements', function test( t ) { - var expected; - var arr; - - function predicate( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - return false; - } - - function verify( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - } - - arr = [ 1, , , 4 ]; // eslint-disable-line no-sparse-arrays - expected = [ 1, void 0, void 0, 4 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); - -tape( 'the function invokes the predicate function and the function to apply with three arguments: value, index, collection', function test( t ) { - var indices; - var values; - var arr; - - function predicate( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - return false; - } - - function verify( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - } - - arr = [ 1, 2, 3, 4 ]; - values = [ 1, 2, 3, 4 ]; - indices = [ 0, 1, 2, 3 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); From 2f6b3b0d2884f0024580ea7eab7e25789b25cbab Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 28 Jul 2024 00:20:35 +0000 Subject: [PATCH 101/135] 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 e95ad7d..caa51b7 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import untilEach from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-until-each@esm/index.mjs'; +import untilEach from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-until-each@v0.2.2-esm/index.mjs'; ``` #### untilEach( collection, predicate, fcn\[, thisArg ] ) @@ -214,7 +214,7 @@ var mean = context.sum / context.count; var isEven = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-even' ).isPrimitive; import randu from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-randu@esm/index.mjs'; import floor from 'https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@esm/index.mjs'; -import untilEach from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-until-each@esm/index.mjs'; +import untilEach from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-until-each@v0.2.2-esm/index.mjs'; function predicate( value ) { return ( value !== value ); From f5b9bf29ab6484ad608a5b8a5ffe28526cf50937 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 28 Jul 2024 00:20:35 +0000 Subject: [PATCH 102/135] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index caa51b7..c4ce594 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ limitations under the License. ## Usage +```javascript +import untilEach from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-until-each@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/utils-until-each/tags). For example, + ```javascript import untilEach from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-until-each@v0.2.2-esm/index.mjs'; ``` @@ -214,7 +219,7 @@ var mean = context.sum / context.count; var isEven = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-even' ).isPrimitive; import randu from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-randu@esm/index.mjs'; import floor from 'https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-floor@esm/index.mjs'; -import untilEach from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-until-each@v0.2.2-esm/index.mjs'; +import untilEach from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-until-each@esm/index.mjs'; function predicate( value ) { return ( value !== value ); From 8b38c7544f8035e40483861f0c87a6be58199344 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 04:20:55 +0000 Subject: [PATCH 103/135] 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 846d968..42f57a7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,13 +56,13 @@ function untilEach( collection, predicate, fcn, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); + throw new TypeError( format( '1YDAh', collection ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '1YD2H', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '1YD3N', fcn ) ); } len = collection.length; i = 0; diff --git a/package.json b/package.json index 7e8d2f9..5c1f64e 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-collection": "^0.2.2", "@stdlib/assert-is-function": "^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 8e137e4c9a81a309463f535927dad64d0c714543 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 08:16:07 +0000 Subject: [PATCH 104/135] Remove files --- index.d.ts | 142 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4989 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 355b4df..0000000 --- a/index.d.ts +++ /dev/null @@ -1,142 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Checks whether an element in a collection passes a test. -* -* @returns boolean indicating whether an element in a collection passes a test -*/ -type NullaryPredicate = () => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @returns boolean indicating whether an element in a collection passes a test -*/ -type UnaryPredicate = ( value: T ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @returns boolean indicating whether an element in a collection passes a test -*/ -type BinaryPredicate = ( value: T, index: number ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type TernaryPredicate = ( value: T, index: number, collection: Collection ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Predicate = NullaryPredicate | UnaryPredicate | BinaryPredicate | TernaryPredicate; - -/** -* Function invoked for each collection element until test condition is true. -*/ -type Nullary = ( this: U ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -*/ -type Unary = ( this: U, value: T ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -*/ -type Binary = ( this: U, value: T, index: number ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Ternary = ( this: U, value: T, index: number, collection: Collection ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Until a test condition is true, invokes a function once for each element in a collection. -* -* ## Notes -* -* - When invoked, both the predicate function and the function to apply are provided three arguments: -* -* - `value`: collection value -* - `index`: collection index -* - `collection`: the input collection -* -* @param collection - input collection -* @param predicate - function which indicates whether to stop iterating over a collection -* @param fcn - function to invoke -* @param thisArg - execution context for the applied function -* @returns input collection -* -* @example -* function predicate( v, key, collection ) { -* return ( v !== v ); -* } -* -* function log( v, key, collection ) { -* console.log( '%s: %d', key, v ); -* } -* -* var arr = [ 1, 2, 3, 4, NaN, 5 ]; -* -* untilEach( arr, predicate, log ); -*/ -declare function untilEach( collection: Collection, predicate: Predicate, fcn: Callback, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = untilEach; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 10553a0..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function s(s,o,i,n){var d,l;if(!r(s))throw new TypeError(e("1YDAh",s));if(!t(o))throw new TypeError(e("1YD2H",o));if(!t(i))throw new TypeError(e("1YD3N",i));for(d=s.length,l=0;l - - - - - - Rollup Visualizer - - - -
- - - - - From 80e6e85e90133802a5dee2abc731cc72e2b27f23 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 08:16:19 +0000 Subject: [PATCH 105/135] 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 | 158 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 89 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 47 - docs/types/test.ts | 89 - examples/index.js | 53 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 83 - package.json | 62 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 350 -- 43 files changed, 4868 insertions(+), 4291 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index a51b591..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-08-01T03:06:08.437Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 038a13c..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/utils/until-each) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 4eecda2..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/utils/until-each) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 aa2a9b4..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: '35 11 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -295,7 +286,7 @@ untilEach( arr, predicate, log ); ## 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]. @@ -366,9 +357,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right +[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right/tree/esm -[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each +[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each/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 754724d..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var untilEach = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var sum; - var i; - - function predicate( v ) { - return isnan( v ); - } - - function fcn( v ) { - sum += v; - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - untilEach( arr, predicate, fcn ); - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::loop', function benchmark( b ) { - var sum; - var arr; - var i; - var j; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - j = 0; - while ( j < arr.length ) { - if ( isnan( arr[ j ] ) ) { - break; - } - sum += arr[ j ]; - j += 1; - } - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 5ae3876..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/utils/until-each" -%% click B href "https://github.com/stdlib-js/utils-until-each/tree/main" -%% click C href "https://github.com/stdlib-js/utils-until-each/tree/production" -%% click D href "https://github.com/stdlib-js/utils-until-each/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-until-each/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-until-each/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/until-each -[production-url]: https://github.com/stdlib-js/utils-until-each/tree/production -[deno-url]: https://github.com/stdlib-js/utils-until-each/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-until-each/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-until-each/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-until-each/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-until-each/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-until-each/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 4378886..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import untilEach from '../docs/types/index'; -export = untilEach; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 52eaf73..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var g=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var m=g(function(E,s){ -var h=require('@stdlib/assert-is-collection/dist'),n=require('@stdlib/assert-is-function/dist'),i=require('@stdlib/error-tools-fmtprodmsg/dist');function w(r,e,a,v){var t,u;if(!h(r))throw new TypeError(i('1YDAh',r));if(!n(e))throw new TypeError(i('1YD2H',e));if(!n(a))throw new TypeError(i('1YD3N',a));for(t=r.length,u=0;u function predicate( v ) { return v !== v; }; - > function logger( v, i ) { console.log( '%s: %d', i, v ); }; - > var arr = [ 1, 2, 3, 4, NaN, 5 ]; - > {{alias}}( arr, predicate, logger ) - 0: 1 - 1: 2 - 2: 3 - 3: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4833283..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,89 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 untilEach = require( './index' ); - -/** -* Test function. -* -* @param v - value -* @param index - index -*/ -function fcn( v: number, index: number ): void { - if ( v !== v ) { - throw new Error( 'beep' ); - } - if ( index !== index ) { - throw new Error( 'beep' ); - } -} - -/** -* Test function. -* -* @param v - value -* @returns result -*/ -function isnan( v: number ): boolean { - return ( v !== v ); -} - - -// TESTS // - -// The function returns the input collection... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, fcn ); // $ExpectType Collection - untilEach( [ -1, 1, 2 ], isnan, fcn, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - untilEach( 2, isnan, fcn ); // $ExpectError - untilEach( false, isnan, fcn ); // $ExpectError - untilEach( true, isnan, fcn ); // $ExpectError - untilEach( {}, isnan, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], 2, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], false, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], true, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], 'abc', fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], {}, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], [], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, 2 ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, false ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, true ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, 'abc' ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, {} ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - untilEach(); // $ExpectError - untilEach( [ 1, 2, 3 ] ); // $ExpectError - untilEach( [ 1, 2, 3 ], isnan ); // $ExpectError - untilEach( [ 1, 2, 3 ], isnan, fcn, {}, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index c41d90c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isEven = require( '@stdlib/assert-is-even' ).isPrimitive; -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var untilEach = require( './../lib' ); - -function predicate( value ) { - return ( value !== value ); -} - -function log( value, index, collection ) { - console.log( '%s: %d', index, value ); - if ( isEven( index ) ) { - collection.shift(); - } else { - collection.push( index+1 ); - } -} - -var arr; -var j; -var i; - -arr = new Array( 100 ); -j = floor( randu()*arr.length ); -for ( i = 0; i < arr.length; i++ ) { - if ( i === j ) { - arr[ i ] = NaN; - } else { - arr[ i ] = i; - } -} - -untilEach( arr, predicate, log ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 19fe169..355b4df 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..10553a0 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function s(s,o,i,n){var d,l;if(!r(s))throw new TypeError(e("1YDAh",s));if(!t(o))throw new TypeError(e("1YD2H",o));if(!t(i))throw new TypeError(e("1YD3N",i));for(d=s.length,l=0;l=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b4d9451 --- /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 70a1888..0000000 --- a/test/test.js +++ /dev/null @@ -1,350 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var untilEach = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof untilEach, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {}, - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( value, noop, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a predicate function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a function to invoke', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], noop, value ); - }; - } -}); - -tape( 'if provided an empty collection, the function never invokes a provided function', function test( t ) { - var arr = []; - - function predicate() { - t.fail( 'should not be invoked' ); - } - - function foo() { - t.fail( 'should not be invoked' ); - } - - untilEach( arr, predicate, foo ); - - t.deepEqual( arr, [], 'expected result' ); - t.end(); -}); - -tape( 'the function returns the input collection', function test( t ) { - var arr; - var out; - - function predicate() { - t.pass( 'invoked predicated function' ); - return false; - } - - function foo() { - t.pass( 'invoked provided function' ); - } - - arr = [ 1, 2, 3 ]; - - out = untilEach( arr, predicate, foo ); - - t.strictEqual( out, arr, 'returns input collection' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array)', function test( t ) { - var arr; - var out; - - arr = [ 1, 2, NaN, 3 ]; - out = [ 0, 0, 0, 0 ]; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - untilEach( arr, predicate, copy ); - - t.deepEqual( out, [ 1, 2, 0, 0 ], 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array-like object)', function test( t ) { - var expected; - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = { - 'length': 4, - '0': 1, - '1': 2, - '2': NaN, - '3': 3 - }; - out = { - 'length': 4, - '0': 0, - '1': 0, - '2': 0, - '3': 0 - }; - - untilEach( arr, predicate, copy ); - - expected = { - 'length': 4, - '0': 1, - '1': 2, - '2': 0, - '3': 0 - }; - - t.deepEqual( out, expected, 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (typed array)', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = new Float64Array( [ 1.0, 2.0, NaN, 3.0 ] ); - out = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - untilEach( arr, predicate, copy ); - - t.strictEqual( out[ 0 ], 1.0, 'expected result' ); - t.strictEqual( out[ 1 ], 2.0, 'expected result' ); - t.strictEqual( out[ 2 ], 0.0, 'expected result' ); - t.strictEqual( out[ 3 ], 0.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx; - var arr; - - function predicate( value ) { - return ( value !== value ); - } - - function sum( value ) { - /* eslint-disable no-invalid-this */ - this.sum += value; - this.count += 1; - } - - ctx = { - 'sum': 0, - 'count': 0 - }; - arr = [ 1.0, 2.0, 3.0 ]; - - untilEach( arr, predicate, sum, ctx ); - - t.strictEqual( ctx.sum/ctx.count, 2.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function provides basic support for dynamic arrays', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index, collection ) { - out.push( value ); - if ( index === collection.length-1 && collection.length < 10 ) { - collection.push( index+2 ); - } - } - - arr = [ 1, 2, 3 ]; - out = []; - - untilEach( arr, predicate, copy ); - - t.deepEqual( arr, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.deepEqual( out, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.end(); -}); - -tape( 'the function does not skip empty elements', function test( t ) { - var expected; - var arr; - - function predicate( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - return false; - } - - function verify( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - } - - arr = [ 1, , , 4 ]; // eslint-disable-line no-sparse-arrays - expected = [ 1, void 0, void 0, 4 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); - -tape( 'the function invokes the predicate function and the function to apply with three arguments: value, index, collection', function test( t ) { - var indices; - var values; - var arr; - - function predicate( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - return false; - } - - function verify( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - } - - arr = [ 1, 2, 3, 4 ]; - values = [ 1, 2, 3, 4 ]; - indices = [ 0, 1, 2, 3 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); From 9a7bfdf5790e33e7f6ec88eb58f822475586cd2d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Aug 2024 19:08:19 +0000 Subject: [PATCH 106/135] 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 846d968..42f57a7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,13 +56,13 @@ function untilEach( collection, predicate, fcn, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); + throw new TypeError( format( '1YDAh', collection ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '1YD2H', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '1YD3N', fcn ) ); } len = collection.length; i = 0; diff --git a/package.json b/package.json index 7e8d2f9..5c1f64e 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-collection": "^0.2.2", "@stdlib/assert-is-function": "^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 559f86787639ab1497ef6867e07130d14dea429f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Aug 2024 22:04:19 +0000 Subject: [PATCH 107/135] Remove files --- index.d.ts | 142 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4989 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 355b4df..0000000 --- a/index.d.ts +++ /dev/null @@ -1,142 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Checks whether an element in a collection passes a test. -* -* @returns boolean indicating whether an element in a collection passes a test -*/ -type NullaryPredicate = () => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @returns boolean indicating whether an element in a collection passes a test -*/ -type UnaryPredicate = ( value: T ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @returns boolean indicating whether an element in a collection passes a test -*/ -type BinaryPredicate = ( value: T, index: number ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type TernaryPredicate = ( value: T, index: number, collection: Collection ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Predicate = NullaryPredicate | UnaryPredicate | BinaryPredicate | TernaryPredicate; - -/** -* Function invoked for each collection element until test condition is true. -*/ -type Nullary = ( this: U ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -*/ -type Unary = ( this: U, value: T ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -*/ -type Binary = ( this: U, value: T, index: number ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Ternary = ( this: U, value: T, index: number, collection: Collection ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Until a test condition is true, invokes a function once for each element in a collection. -* -* ## Notes -* -* - When invoked, both the predicate function and the function to apply are provided three arguments: -* -* - `value`: collection value -* - `index`: collection index -* - `collection`: the input collection -* -* @param collection - input collection -* @param predicate - function which indicates whether to stop iterating over a collection -* @param fcn - function to invoke -* @param thisArg - execution context for the applied function -* @returns input collection -* -* @example -* function predicate( v, key, collection ) { -* return ( v !== v ); -* } -* -* function log( v, key, collection ) { -* console.log( '%s: %d', key, v ); -* } -* -* var arr = [ 1, 2, 3, 4, NaN, 5 ]; -* -* untilEach( arr, predicate, log ); -*/ -declare function untilEach( collection: Collection, predicate: Predicate, fcn: Callback, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = untilEach; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 10553a0..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function s(s,o,i,n){var d,l;if(!r(s))throw new TypeError(e("1YDAh",s));if(!t(o))throw new TypeError(e("1YD2H",o));if(!t(i))throw new TypeError(e("1YD3N",i));for(d=s.length,l=0;l - - - - - - Rollup Visualizer - - - -
- - - - - From 6b355837e3468b40d4436388122aacaddb7d0090 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Aug 2024 22:04:34 +0000 Subject: [PATCH 108/135] 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 | 184 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 89 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 47 - docs/types/test.ts | 89 - examples/index.js | 53 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 83 - package.json | 62 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 350 -- 43 files changed, 4868 insertions(+), 4317 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index bb9ac46..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-08-03T18:12:52.554Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 038a13c..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/utils/until-each) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 4eecda2..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/utils/until-each) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 aa2a9b4..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: '35 11 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -295,7 +286,7 @@ untilEach( arr, predicate, log ); ## 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]. @@ -366,9 +357,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right +[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right/tree/esm -[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each +[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each/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 754724d..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var untilEach = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var sum; - var i; - - function predicate( v ) { - return isnan( v ); - } - - function fcn( v ) { - sum += v; - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - untilEach( arr, predicate, fcn ); - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::loop', function benchmark( b ) { - var sum; - var arr; - var i; - var j; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - j = 0; - while ( j < arr.length ) { - if ( isnan( arr[ j ] ) ) { - break; - } - sum += arr[ j ]; - j += 1; - } - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 5ae3876..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/utils/until-each" -%% click B href "https://github.com/stdlib-js/utils-until-each/tree/main" -%% click C href "https://github.com/stdlib-js/utils-until-each/tree/production" -%% click D href "https://github.com/stdlib-js/utils-until-each/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-until-each/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-until-each/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/until-each -[production-url]: https://github.com/stdlib-js/utils-until-each/tree/production -[deno-url]: https://github.com/stdlib-js/utils-until-each/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-until-each/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-until-each/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-until-each/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-until-each/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-until-each/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 4378886..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import untilEach from '../docs/types/index'; -export = untilEach; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 52eaf73..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var g=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var m=g(function(E,s){ -var h=require('@stdlib/assert-is-collection/dist'),n=require('@stdlib/assert-is-function/dist'),i=require('@stdlib/error-tools-fmtprodmsg/dist');function w(r,e,a,v){var t,u;if(!h(r))throw new TypeError(i('1YDAh',r));if(!n(e))throw new TypeError(i('1YD2H',e));if(!n(a))throw new TypeError(i('1YD3N',a));for(t=r.length,u=0;u function predicate( v ) { return v !== v; }; - > function logger( v, i ) { console.log( '%s: %d', i, v ); }; - > var arr = [ 1, 2, 3, 4, NaN, 5 ]; - > {{alias}}( arr, predicate, logger ) - 0: 1 - 1: 2 - 2: 3 - 3: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4833283..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,89 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 untilEach = require( './index' ); - -/** -* Test function. -* -* @param v - value -* @param index - index -*/ -function fcn( v: number, index: number ): void { - if ( v !== v ) { - throw new Error( 'beep' ); - } - if ( index !== index ) { - throw new Error( 'beep' ); - } -} - -/** -* Test function. -* -* @param v - value -* @returns result -*/ -function isnan( v: number ): boolean { - return ( v !== v ); -} - - -// TESTS // - -// The function returns the input collection... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, fcn ); // $ExpectType Collection - untilEach( [ -1, 1, 2 ], isnan, fcn, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - untilEach( 2, isnan, fcn ); // $ExpectError - untilEach( false, isnan, fcn ); // $ExpectError - untilEach( true, isnan, fcn ); // $ExpectError - untilEach( {}, isnan, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], 2, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], false, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], true, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], 'abc', fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], {}, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], [], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, 2 ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, false ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, true ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, 'abc' ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, {} ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - untilEach(); // $ExpectError - untilEach( [ 1, 2, 3 ] ); // $ExpectError - untilEach( [ 1, 2, 3 ], isnan ); // $ExpectError - untilEach( [ 1, 2, 3 ], isnan, fcn, {}, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index c41d90c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isEven = require( '@stdlib/assert-is-even' ).isPrimitive; -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var untilEach = require( './../lib' ); - -function predicate( value ) { - return ( value !== value ); -} - -function log( value, index, collection ) { - console.log( '%s: %d', index, value ); - if ( isEven( index ) ) { - collection.shift(); - } else { - collection.push( index+1 ); - } -} - -var arr; -var j; -var i; - -arr = new Array( 100 ); -j = floor( randu()*arr.length ); -for ( i = 0; i < arr.length; i++ ) { - if ( i === j ) { - arr[ i ] = NaN; - } else { - arr[ i ] = i; - } -} - -untilEach( arr, predicate, log ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 19fe169..355b4df 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..10553a0 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function s(s,o,i,n){var d,l;if(!r(s))throw new TypeError(e("1YDAh",s));if(!t(o))throw new TypeError(e("1YD2H",o));if(!t(i))throw new TypeError(e("1YD3N",i));for(d=s.length,l=0;l=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b4d9451 --- /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 70a1888..0000000 --- a/test/test.js +++ /dev/null @@ -1,350 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var untilEach = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof untilEach, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {}, - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( value, noop, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a predicate function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a function to invoke', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], noop, value ); - }; - } -}); - -tape( 'if provided an empty collection, the function never invokes a provided function', function test( t ) { - var arr = []; - - function predicate() { - t.fail( 'should not be invoked' ); - } - - function foo() { - t.fail( 'should not be invoked' ); - } - - untilEach( arr, predicate, foo ); - - t.deepEqual( arr, [], 'expected result' ); - t.end(); -}); - -tape( 'the function returns the input collection', function test( t ) { - var arr; - var out; - - function predicate() { - t.pass( 'invoked predicated function' ); - return false; - } - - function foo() { - t.pass( 'invoked provided function' ); - } - - arr = [ 1, 2, 3 ]; - - out = untilEach( arr, predicate, foo ); - - t.strictEqual( out, arr, 'returns input collection' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array)', function test( t ) { - var arr; - var out; - - arr = [ 1, 2, NaN, 3 ]; - out = [ 0, 0, 0, 0 ]; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - untilEach( arr, predicate, copy ); - - t.deepEqual( out, [ 1, 2, 0, 0 ], 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array-like object)', function test( t ) { - var expected; - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = { - 'length': 4, - '0': 1, - '1': 2, - '2': NaN, - '3': 3 - }; - out = { - 'length': 4, - '0': 0, - '1': 0, - '2': 0, - '3': 0 - }; - - untilEach( arr, predicate, copy ); - - expected = { - 'length': 4, - '0': 1, - '1': 2, - '2': 0, - '3': 0 - }; - - t.deepEqual( out, expected, 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (typed array)', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = new Float64Array( [ 1.0, 2.0, NaN, 3.0 ] ); - out = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - untilEach( arr, predicate, copy ); - - t.strictEqual( out[ 0 ], 1.0, 'expected result' ); - t.strictEqual( out[ 1 ], 2.0, 'expected result' ); - t.strictEqual( out[ 2 ], 0.0, 'expected result' ); - t.strictEqual( out[ 3 ], 0.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx; - var arr; - - function predicate( value ) { - return ( value !== value ); - } - - function sum( value ) { - /* eslint-disable no-invalid-this */ - this.sum += value; - this.count += 1; - } - - ctx = { - 'sum': 0, - 'count': 0 - }; - arr = [ 1.0, 2.0, 3.0 ]; - - untilEach( arr, predicate, sum, ctx ); - - t.strictEqual( ctx.sum/ctx.count, 2.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function provides basic support for dynamic arrays', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index, collection ) { - out.push( value ); - if ( index === collection.length-1 && collection.length < 10 ) { - collection.push( index+2 ); - } - } - - arr = [ 1, 2, 3 ]; - out = []; - - untilEach( arr, predicate, copy ); - - t.deepEqual( arr, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.deepEqual( out, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.end(); -}); - -tape( 'the function does not skip empty elements', function test( t ) { - var expected; - var arr; - - function predicate( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - return false; - } - - function verify( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - } - - arr = [ 1, , , 4 ]; // eslint-disable-line no-sparse-arrays - expected = [ 1, void 0, void 0, 4 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); - -tape( 'the function invokes the predicate function and the function to apply with three arguments: value, index, collection', function test( t ) { - var indices; - var values; - var arr; - - function predicate( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - return false; - } - - function verify( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - } - - arr = [ 1, 2, 3, 4 ]; - values = [ 1, 2, 3, 4 ]; - indices = [ 0, 1, 2, 3 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); From 5946643862da6b2a89452c751c8a5634ecabea96 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 04:27:01 +0000 Subject: [PATCH 109/135] 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 846d968..42f57a7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,13 +56,13 @@ function untilEach( collection, predicate, fcn, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); + throw new TypeError( format( '1YDAh', collection ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '1YD2H', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '1YD3N', fcn ) ); } len = collection.length; i = 0; diff --git a/package.json b/package.json index b2bcfe3..8898c2a 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-collection": "^0.2.2", "@stdlib/assert-is-function": "^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 87516c9a87c1dc89c1fb2ac4a3a708dc5814512a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 08:02:19 +0000 Subject: [PATCH 110/135] Remove files --- index.d.ts | 142 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4989 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 355b4df..0000000 --- a/index.d.ts +++ /dev/null @@ -1,142 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Checks whether an element in a collection passes a test. -* -* @returns boolean indicating whether an element in a collection passes a test -*/ -type NullaryPredicate = () => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @returns boolean indicating whether an element in a collection passes a test -*/ -type UnaryPredicate = ( value: T ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @returns boolean indicating whether an element in a collection passes a test -*/ -type BinaryPredicate = ( value: T, index: number ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type TernaryPredicate = ( value: T, index: number, collection: Collection ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Predicate = NullaryPredicate | UnaryPredicate | BinaryPredicate | TernaryPredicate; - -/** -* Function invoked for each collection element until test condition is true. -*/ -type Nullary = ( this: U ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -*/ -type Unary = ( this: U, value: T ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -*/ -type Binary = ( this: U, value: T, index: number ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Ternary = ( this: U, value: T, index: number, collection: Collection ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Until a test condition is true, invokes a function once for each element in a collection. -* -* ## Notes -* -* - When invoked, both the predicate function and the function to apply are provided three arguments: -* -* - `value`: collection value -* - `index`: collection index -* - `collection`: the input collection -* -* @param collection - input collection -* @param predicate - function which indicates whether to stop iterating over a collection -* @param fcn - function to invoke -* @param thisArg - execution context for the applied function -* @returns input collection -* -* @example -* function predicate( v, key, collection ) { -* return ( v !== v ); -* } -* -* function log( v, key, collection ) { -* console.log( '%s: %d', key, v ); -* } -* -* var arr = [ 1, 2, 3, 4, NaN, 5 ]; -* -* untilEach( arr, predicate, log ); -*/ -declare function untilEach( collection: Collection, predicate: Predicate, fcn: Callback, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = untilEach; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 10553a0..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function s(s,o,i,n){var d,l;if(!r(s))throw new TypeError(e("1YDAh",s));if(!t(o))throw new TypeError(e("1YD2H",o));if(!t(i))throw new TypeError(e("1YD3N",i));for(d=s.length,l=0;l - - - - - - Rollup Visualizer - - - -
- - - - - From 79464e64406d22ed35c353101bf0d9e425b538a2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 08:02:31 +0000 Subject: [PATCH 111/135] 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 | 184 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 89 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 47 - docs/types/test.ts | 89 - examples/index.js | 53 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 83 - package.json | 62 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 350 -- 43 files changed, 4868 insertions(+), 4317 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 1090f3a..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-09-01T03:17:44.825Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 038a13c..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/utils/until-each) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 4eecda2..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/utils/until-each) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 aa2a9b4..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: '35 11 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -295,7 +286,7 @@ untilEach( arr, predicate, log ); ## 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]. @@ -366,9 +357,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right +[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right/tree/esm -[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each +[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each/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 754724d..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var untilEach = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var sum; - var i; - - function predicate( v ) { - return isnan( v ); - } - - function fcn( v ) { - sum += v; - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - untilEach( arr, predicate, fcn ); - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::loop', function benchmark( b ) { - var sum; - var arr; - var i; - var j; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - j = 0; - while ( j < arr.length ) { - if ( isnan( arr[ j ] ) ) { - break; - } - sum += arr[ j ]; - j += 1; - } - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 5ae3876..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/utils/until-each" -%% click B href "https://github.com/stdlib-js/utils-until-each/tree/main" -%% click C href "https://github.com/stdlib-js/utils-until-each/tree/production" -%% click D href "https://github.com/stdlib-js/utils-until-each/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-until-each/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-until-each/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/until-each -[production-url]: https://github.com/stdlib-js/utils-until-each/tree/production -[deno-url]: https://github.com/stdlib-js/utils-until-each/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-until-each/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-until-each/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-until-each/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-until-each/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-until-each/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 4378886..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import untilEach from '../docs/types/index'; -export = untilEach; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 52eaf73..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var g=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var m=g(function(E,s){ -var h=require('@stdlib/assert-is-collection/dist'),n=require('@stdlib/assert-is-function/dist'),i=require('@stdlib/error-tools-fmtprodmsg/dist');function w(r,e,a,v){var t,u;if(!h(r))throw new TypeError(i('1YDAh',r));if(!n(e))throw new TypeError(i('1YD2H',e));if(!n(a))throw new TypeError(i('1YD3N',a));for(t=r.length,u=0;u function predicate( v ) { return v !== v; }; - > function logger( v, i ) { console.log( '%s: %d', i, v ); }; - > var arr = [ 1, 2, 3, 4, NaN, 5 ]; - > {{alias}}( arr, predicate, logger ) - 0: 1 - 1: 2 - 2: 3 - 3: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4833283..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,89 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 untilEach = require( './index' ); - -/** -* Test function. -* -* @param v - value -* @param index - index -*/ -function fcn( v: number, index: number ): void { - if ( v !== v ) { - throw new Error( 'beep' ); - } - if ( index !== index ) { - throw new Error( 'beep' ); - } -} - -/** -* Test function. -* -* @param v - value -* @returns result -*/ -function isnan( v: number ): boolean { - return ( v !== v ); -} - - -// TESTS // - -// The function returns the input collection... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, fcn ); // $ExpectType Collection - untilEach( [ -1, 1, 2 ], isnan, fcn, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - untilEach( 2, isnan, fcn ); // $ExpectError - untilEach( false, isnan, fcn ); // $ExpectError - untilEach( true, isnan, fcn ); // $ExpectError - untilEach( {}, isnan, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], 2, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], false, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], true, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], 'abc', fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], {}, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], [], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, 2 ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, false ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, true ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, 'abc' ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, {} ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - untilEach(); // $ExpectError - untilEach( [ 1, 2, 3 ] ); // $ExpectError - untilEach( [ 1, 2, 3 ], isnan ); // $ExpectError - untilEach( [ 1, 2, 3 ], isnan, fcn, {}, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index c41d90c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isEven = require( '@stdlib/assert-is-even' ).isPrimitive; -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var untilEach = require( './../lib' ); - -function predicate( value ) { - return ( value !== value ); -} - -function log( value, index, collection ) { - console.log( '%s: %d', index, value ); - if ( isEven( index ) ) { - collection.shift(); - } else { - collection.push( index+1 ); - } -} - -var arr; -var j; -var i; - -arr = new Array( 100 ); -j = floor( randu()*arr.length ); -for ( i = 0; i < arr.length; i++ ) { - if ( i === j ) { - arr[ i ] = NaN; - } else { - arr[ i ] = i; - } -} - -untilEach( arr, predicate, log ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 19fe169..355b4df 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..10553a0 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function s(s,o,i,n){var d,l;if(!r(s))throw new TypeError(e("1YDAh",s));if(!t(o))throw new TypeError(e("1YD2H",o));if(!t(i))throw new TypeError(e("1YD3N",i));for(d=s.length,l=0;l=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b4d9451 --- /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 70a1888..0000000 --- a/test/test.js +++ /dev/null @@ -1,350 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var untilEach = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof untilEach, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {}, - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( value, noop, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a predicate function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a function to invoke', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], noop, value ); - }; - } -}); - -tape( 'if provided an empty collection, the function never invokes a provided function', function test( t ) { - var arr = []; - - function predicate() { - t.fail( 'should not be invoked' ); - } - - function foo() { - t.fail( 'should not be invoked' ); - } - - untilEach( arr, predicate, foo ); - - t.deepEqual( arr, [], 'expected result' ); - t.end(); -}); - -tape( 'the function returns the input collection', function test( t ) { - var arr; - var out; - - function predicate() { - t.pass( 'invoked predicated function' ); - return false; - } - - function foo() { - t.pass( 'invoked provided function' ); - } - - arr = [ 1, 2, 3 ]; - - out = untilEach( arr, predicate, foo ); - - t.strictEqual( out, arr, 'returns input collection' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array)', function test( t ) { - var arr; - var out; - - arr = [ 1, 2, NaN, 3 ]; - out = [ 0, 0, 0, 0 ]; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - untilEach( arr, predicate, copy ); - - t.deepEqual( out, [ 1, 2, 0, 0 ], 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array-like object)', function test( t ) { - var expected; - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = { - 'length': 4, - '0': 1, - '1': 2, - '2': NaN, - '3': 3 - }; - out = { - 'length': 4, - '0': 0, - '1': 0, - '2': 0, - '3': 0 - }; - - untilEach( arr, predicate, copy ); - - expected = { - 'length': 4, - '0': 1, - '1': 2, - '2': 0, - '3': 0 - }; - - t.deepEqual( out, expected, 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (typed array)', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = new Float64Array( [ 1.0, 2.0, NaN, 3.0 ] ); - out = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - untilEach( arr, predicate, copy ); - - t.strictEqual( out[ 0 ], 1.0, 'expected result' ); - t.strictEqual( out[ 1 ], 2.0, 'expected result' ); - t.strictEqual( out[ 2 ], 0.0, 'expected result' ); - t.strictEqual( out[ 3 ], 0.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx; - var arr; - - function predicate( value ) { - return ( value !== value ); - } - - function sum( value ) { - /* eslint-disable no-invalid-this */ - this.sum += value; - this.count += 1; - } - - ctx = { - 'sum': 0, - 'count': 0 - }; - arr = [ 1.0, 2.0, 3.0 ]; - - untilEach( arr, predicate, sum, ctx ); - - t.strictEqual( ctx.sum/ctx.count, 2.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function provides basic support for dynamic arrays', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index, collection ) { - out.push( value ); - if ( index === collection.length-1 && collection.length < 10 ) { - collection.push( index+2 ); - } - } - - arr = [ 1, 2, 3 ]; - out = []; - - untilEach( arr, predicate, copy ); - - t.deepEqual( arr, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.deepEqual( out, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.end(); -}); - -tape( 'the function does not skip empty elements', function test( t ) { - var expected; - var arr; - - function predicate( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - return false; - } - - function verify( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - } - - arr = [ 1, , , 4 ]; // eslint-disable-line no-sparse-arrays - expected = [ 1, void 0, void 0, 4 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); - -tape( 'the function invokes the predicate function and the function to apply with three arguments: value, index, collection', function test( t ) { - var indices; - var values; - var arr; - - function predicate( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - return false; - } - - function verify( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - } - - arr = [ 1, 2, 3, 4 ]; - values = [ 1, 2, 3, 4 ]; - indices = [ 0, 1, 2, 3 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); From 4611fc9ebfb9a777b53084172ecefb159d29143e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 17 Sep 2024 02:22:42 +0000 Subject: [PATCH 112/135] 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 846d968..42f57a7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,13 +56,13 @@ function untilEach( collection, predicate, fcn, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); + throw new TypeError( format( '1YDAh', collection ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '1YD2H', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '1YD3N', fcn ) ); } len = collection.length; i = 0; diff --git a/package.json b/package.json index b2bcfe3..8898c2a 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-collection": "^0.2.2", "@stdlib/assert-is-function": "^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 29e157625279bb97dd492ce60553e0da9dcfc8cd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 17 Sep 2024 02:33:17 +0000 Subject: [PATCH 113/135] Remove files --- index.d.ts | 142 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4989 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 355b4df..0000000 --- a/index.d.ts +++ /dev/null @@ -1,142 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Checks whether an element in a collection passes a test. -* -* @returns boolean indicating whether an element in a collection passes a test -*/ -type NullaryPredicate = () => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @returns boolean indicating whether an element in a collection passes a test -*/ -type UnaryPredicate = ( value: T ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @returns boolean indicating whether an element in a collection passes a test -*/ -type BinaryPredicate = ( value: T, index: number ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type TernaryPredicate = ( value: T, index: number, collection: Collection ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Predicate = NullaryPredicate | UnaryPredicate | BinaryPredicate | TernaryPredicate; - -/** -* Function invoked for each collection element until test condition is true. -*/ -type Nullary = ( this: U ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -*/ -type Unary = ( this: U, value: T ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -*/ -type Binary = ( this: U, value: T, index: number ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Ternary = ( this: U, value: T, index: number, collection: Collection ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Until a test condition is true, invokes a function once for each element in a collection. -* -* ## Notes -* -* - When invoked, both the predicate function and the function to apply are provided three arguments: -* -* - `value`: collection value -* - `index`: collection index -* - `collection`: the input collection -* -* @param collection - input collection -* @param predicate - function which indicates whether to stop iterating over a collection -* @param fcn - function to invoke -* @param thisArg - execution context for the applied function -* @returns input collection -* -* @example -* function predicate( v, key, collection ) { -* return ( v !== v ); -* } -* -* function log( v, key, collection ) { -* console.log( '%s: %d', key, v ); -* } -* -* var arr = [ 1, 2, 3, 4, NaN, 5 ]; -* -* untilEach( arr, predicate, log ); -*/ -declare function untilEach( collection: Collection, predicate: Predicate, fcn: Callback, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = untilEach; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 10553a0..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function s(s,o,i,n){var d,l;if(!r(s))throw new TypeError(e("1YDAh",s));if(!t(o))throw new TypeError(e("1YD2H",o));if(!t(i))throw new TypeError(e("1YD3N",i));for(d=s.length,l=0;l - - - - - - Rollup Visualizer - - - -
- - - - - From 43edee4e933ab3d6138f5a8fe61618411d34c496 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 17 Sep 2024 02:33:30 +0000 Subject: [PATCH 114/135] 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 | 218 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 89 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 47 - docs/types/test.ts | 89 - examples/index.js | 53 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 83 - package.json | 62 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 350 -- 42 files changed, 4868 insertions(+), 4350 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 038a13c..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/utils/until-each) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 4eecda2..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/utils/until-each) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 aa2a9b4..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: '35 11 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -295,7 +286,7 @@ untilEach( arr, predicate, log ); ## 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]. @@ -366,9 +357,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right +[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right/tree/esm -[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each +[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each/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 754724d..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var untilEach = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var sum; - var i; - - function predicate( v ) { - return isnan( v ); - } - - function fcn( v ) { - sum += v; - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - untilEach( arr, predicate, fcn ); - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::loop', function benchmark( b ) { - var sum; - var arr; - var i; - var j; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - j = 0; - while ( j < arr.length ) { - if ( isnan( arr[ j ] ) ) { - break; - } - sum += arr[ j ]; - j += 1; - } - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 5ae3876..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/utils/until-each" -%% click B href "https://github.com/stdlib-js/utils-until-each/tree/main" -%% click C href "https://github.com/stdlib-js/utils-until-each/tree/production" -%% click D href "https://github.com/stdlib-js/utils-until-each/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-until-each/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-until-each/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/until-each -[production-url]: https://github.com/stdlib-js/utils-until-each/tree/production -[deno-url]: https://github.com/stdlib-js/utils-until-each/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-until-each/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-until-each/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-until-each/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-until-each/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-until-each/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 4378886..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import untilEach from '../docs/types/index'; -export = untilEach; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 52eaf73..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var g=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var m=g(function(E,s){ -var h=require('@stdlib/assert-is-collection/dist'),n=require('@stdlib/assert-is-function/dist'),i=require('@stdlib/error-tools-fmtprodmsg/dist');function w(r,e,a,v){var t,u;if(!h(r))throw new TypeError(i('1YDAh',r));if(!n(e))throw new TypeError(i('1YD2H',e));if(!n(a))throw new TypeError(i('1YD3N',a));for(t=r.length,u=0;u function predicate( v ) { return v !== v; }; - > function logger( v, i ) { console.log( '%s: %d', i, v ); }; - > var arr = [ 1, 2, 3, 4, NaN, 5 ]; - > {{alias}}( arr, predicate, logger ) - 0: 1 - 1: 2 - 2: 3 - 3: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4833283..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,89 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 untilEach = require( './index' ); - -/** -* Test function. -* -* @param v - value -* @param index - index -*/ -function fcn( v: number, index: number ): void { - if ( v !== v ) { - throw new Error( 'beep' ); - } - if ( index !== index ) { - throw new Error( 'beep' ); - } -} - -/** -* Test function. -* -* @param v - value -* @returns result -*/ -function isnan( v: number ): boolean { - return ( v !== v ); -} - - -// TESTS // - -// The function returns the input collection... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, fcn ); // $ExpectType Collection - untilEach( [ -1, 1, 2 ], isnan, fcn, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - untilEach( 2, isnan, fcn ); // $ExpectError - untilEach( false, isnan, fcn ); // $ExpectError - untilEach( true, isnan, fcn ); // $ExpectError - untilEach( {}, isnan, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], 2, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], false, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], true, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], 'abc', fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], {}, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], [], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, 2 ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, false ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, true ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, 'abc' ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, {} ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - untilEach(); // $ExpectError - untilEach( [ 1, 2, 3 ] ); // $ExpectError - untilEach( [ 1, 2, 3 ], isnan ); // $ExpectError - untilEach( [ 1, 2, 3 ], isnan, fcn, {}, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index c41d90c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isEven = require( '@stdlib/assert-is-even' ).isPrimitive; -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var untilEach = require( './../lib' ); - -function predicate( value ) { - return ( value !== value ); -} - -function log( value, index, collection ) { - console.log( '%s: %d', index, value ); - if ( isEven( index ) ) { - collection.shift(); - } else { - collection.push( index+1 ); - } -} - -var arr; -var j; -var i; - -arr = new Array( 100 ); -j = floor( randu()*arr.length ); -for ( i = 0; i < arr.length; i++ ) { - if ( i === j ) { - arr[ i ] = NaN; - } else { - arr[ i ] = i; - } -} - -untilEach( arr, predicate, log ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 19fe169..355b4df 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..10553a0 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function s(s,o,i,n){var d,l;if(!r(s))throw new TypeError(e("1YDAh",s));if(!t(o))throw new TypeError(e("1YD2H",o));if(!t(i))throw new TypeError(e("1YD3N",i));for(d=s.length,l=0;l=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b4d9451 --- /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 70a1888..0000000 --- a/test/test.js +++ /dev/null @@ -1,350 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var untilEach = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof untilEach, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {}, - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( value, noop, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a predicate function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a function to invoke', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], noop, value ); - }; - } -}); - -tape( 'if provided an empty collection, the function never invokes a provided function', function test( t ) { - var arr = []; - - function predicate() { - t.fail( 'should not be invoked' ); - } - - function foo() { - t.fail( 'should not be invoked' ); - } - - untilEach( arr, predicate, foo ); - - t.deepEqual( arr, [], 'expected result' ); - t.end(); -}); - -tape( 'the function returns the input collection', function test( t ) { - var arr; - var out; - - function predicate() { - t.pass( 'invoked predicated function' ); - return false; - } - - function foo() { - t.pass( 'invoked provided function' ); - } - - arr = [ 1, 2, 3 ]; - - out = untilEach( arr, predicate, foo ); - - t.strictEqual( out, arr, 'returns input collection' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array)', function test( t ) { - var arr; - var out; - - arr = [ 1, 2, NaN, 3 ]; - out = [ 0, 0, 0, 0 ]; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - untilEach( arr, predicate, copy ); - - t.deepEqual( out, [ 1, 2, 0, 0 ], 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array-like object)', function test( t ) { - var expected; - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = { - 'length': 4, - '0': 1, - '1': 2, - '2': NaN, - '3': 3 - }; - out = { - 'length': 4, - '0': 0, - '1': 0, - '2': 0, - '3': 0 - }; - - untilEach( arr, predicate, copy ); - - expected = { - 'length': 4, - '0': 1, - '1': 2, - '2': 0, - '3': 0 - }; - - t.deepEqual( out, expected, 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (typed array)', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = new Float64Array( [ 1.0, 2.0, NaN, 3.0 ] ); - out = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - untilEach( arr, predicate, copy ); - - t.strictEqual( out[ 0 ], 1.0, 'expected result' ); - t.strictEqual( out[ 1 ], 2.0, 'expected result' ); - t.strictEqual( out[ 2 ], 0.0, 'expected result' ); - t.strictEqual( out[ 3 ], 0.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx; - var arr; - - function predicate( value ) { - return ( value !== value ); - } - - function sum( value ) { - /* eslint-disable no-invalid-this */ - this.sum += value; - this.count += 1; - } - - ctx = { - 'sum': 0, - 'count': 0 - }; - arr = [ 1.0, 2.0, 3.0 ]; - - untilEach( arr, predicate, sum, ctx ); - - t.strictEqual( ctx.sum/ctx.count, 2.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function provides basic support for dynamic arrays', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index, collection ) { - out.push( value ); - if ( index === collection.length-1 && collection.length < 10 ) { - collection.push( index+2 ); - } - } - - arr = [ 1, 2, 3 ]; - out = []; - - untilEach( arr, predicate, copy ); - - t.deepEqual( arr, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.deepEqual( out, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.end(); -}); - -tape( 'the function does not skip empty elements', function test( t ) { - var expected; - var arr; - - function predicate( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - return false; - } - - function verify( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - } - - arr = [ 1, , , 4 ]; // eslint-disable-line no-sparse-arrays - expected = [ 1, void 0, void 0, 4 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); - -tape( 'the function invokes the predicate function and the function to apply with three arguments: value, index, collection', function test( t ) { - var indices; - var values; - var arr; - - function predicate( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - return false; - } - - function verify( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - } - - arr = [ 1, 2, 3, 4 ]; - values = [ 1, 2, 3, 4 ]; - indices = [ 0, 1, 2, 3 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); From 377a0b884c222b985fa2b9cf8e8cde34fe2fa8ec Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 21 Sep 2024 22:00:55 +0000 Subject: [PATCH 115/135] 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 846d968..42f57a7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,13 +56,13 @@ function untilEach( collection, predicate, fcn, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); + throw new TypeError( format( '1YDAh', collection ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '1YD2H', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '1YD3N', fcn ) ); } len = collection.length; i = 0; diff --git a/package.json b/package.json index b2bcfe3..8898c2a 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-collection": "^0.2.2", "@stdlib/assert-is-function": "^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 9847d314c4fedc559c8b91b7d5a12382fd382b70 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 21 Sep 2024 22:28:47 +0000 Subject: [PATCH 116/135] Remove files --- index.d.ts | 142 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4989 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 355b4df..0000000 --- a/index.d.ts +++ /dev/null @@ -1,142 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Checks whether an element in a collection passes a test. -* -* @returns boolean indicating whether an element in a collection passes a test -*/ -type NullaryPredicate = () => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @returns boolean indicating whether an element in a collection passes a test -*/ -type UnaryPredicate = ( value: T ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @returns boolean indicating whether an element in a collection passes a test -*/ -type BinaryPredicate = ( value: T, index: number ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type TernaryPredicate = ( value: T, index: number, collection: Collection ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Predicate = NullaryPredicate | UnaryPredicate | BinaryPredicate | TernaryPredicate; - -/** -* Function invoked for each collection element until test condition is true. -*/ -type Nullary = ( this: U ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -*/ -type Unary = ( this: U, value: T ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -*/ -type Binary = ( this: U, value: T, index: number ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Ternary = ( this: U, value: T, index: number, collection: Collection ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Until a test condition is true, invokes a function once for each element in a collection. -* -* ## Notes -* -* - When invoked, both the predicate function and the function to apply are provided three arguments: -* -* - `value`: collection value -* - `index`: collection index -* - `collection`: the input collection -* -* @param collection - input collection -* @param predicate - function which indicates whether to stop iterating over a collection -* @param fcn - function to invoke -* @param thisArg - execution context for the applied function -* @returns input collection -* -* @example -* function predicate( v, key, collection ) { -* return ( v !== v ); -* } -* -* function log( v, key, collection ) { -* console.log( '%s: %d', key, v ); -* } -* -* var arr = [ 1, 2, 3, 4, NaN, 5 ]; -* -* untilEach( arr, predicate, log ); -*/ -declare function untilEach( collection: Collection, predicate: Predicate, fcn: Callback, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = untilEach; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 10553a0..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function s(s,o,i,n){var d,l;if(!r(s))throw new TypeError(e("1YDAh",s));if(!t(o))throw new TypeError(e("1YD2H",o));if(!t(i))throw new TypeError(e("1YD3N",i));for(d=s.length,l=0;l - - - - - - Rollup Visualizer - - - -
- - - - - From a1195572ff0273476b9bb699d3dbbeb1fbb7da08 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 21 Sep 2024 22:29:01 +0000 Subject: [PATCH 117/135] 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 | 219 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 89 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 47 - docs/types/test.ts | 89 - examples/index.js | 53 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 83 - package.json | 62 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 350 -- 42 files changed, 4868 insertions(+), 4351 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 038a13c..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/utils/until-each) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 4eecda2..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/utils/until-each) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 aa2a9b4..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: '35 11 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -295,7 +286,7 @@ untilEach( arr, predicate, log ); ## 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]. @@ -366,9 +357,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right +[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right/tree/esm -[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each +[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each/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 754724d..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var untilEach = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var sum; - var i; - - function predicate( v ) { - return isnan( v ); - } - - function fcn( v ) { - sum += v; - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - untilEach( arr, predicate, fcn ); - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::loop', function benchmark( b ) { - var sum; - var arr; - var i; - var j; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - j = 0; - while ( j < arr.length ) { - if ( isnan( arr[ j ] ) ) { - break; - } - sum += arr[ j ]; - j += 1; - } - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 5ae3876..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/utils/until-each" -%% click B href "https://github.com/stdlib-js/utils-until-each/tree/main" -%% click C href "https://github.com/stdlib-js/utils-until-each/tree/production" -%% click D href "https://github.com/stdlib-js/utils-until-each/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-until-each/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-until-each/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/until-each -[production-url]: https://github.com/stdlib-js/utils-until-each/tree/production -[deno-url]: https://github.com/stdlib-js/utils-until-each/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-until-each/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-until-each/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-until-each/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-until-each/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-until-each/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 4378886..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import untilEach from '../docs/types/index'; -export = untilEach; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 52eaf73..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var g=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var m=g(function(E,s){ -var h=require('@stdlib/assert-is-collection/dist'),n=require('@stdlib/assert-is-function/dist'),i=require('@stdlib/error-tools-fmtprodmsg/dist');function w(r,e,a,v){var t,u;if(!h(r))throw new TypeError(i('1YDAh',r));if(!n(e))throw new TypeError(i('1YD2H',e));if(!n(a))throw new TypeError(i('1YD3N',a));for(t=r.length,u=0;u function predicate( v ) { return v !== v; }; - > function logger( v, i ) { console.log( '%s: %d', i, v ); }; - > var arr = [ 1, 2, 3, 4, NaN, 5 ]; - > {{alias}}( arr, predicate, logger ) - 0: 1 - 1: 2 - 2: 3 - 3: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4833283..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,89 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 untilEach = require( './index' ); - -/** -* Test function. -* -* @param v - value -* @param index - index -*/ -function fcn( v: number, index: number ): void { - if ( v !== v ) { - throw new Error( 'beep' ); - } - if ( index !== index ) { - throw new Error( 'beep' ); - } -} - -/** -* Test function. -* -* @param v - value -* @returns result -*/ -function isnan( v: number ): boolean { - return ( v !== v ); -} - - -// TESTS // - -// The function returns the input collection... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, fcn ); // $ExpectType Collection - untilEach( [ -1, 1, 2 ], isnan, fcn, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - untilEach( 2, isnan, fcn ); // $ExpectError - untilEach( false, isnan, fcn ); // $ExpectError - untilEach( true, isnan, fcn ); // $ExpectError - untilEach( {}, isnan, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], 2, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], false, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], true, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], 'abc', fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], {}, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], [], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, 2 ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, false ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, true ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, 'abc' ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, {} ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - untilEach(); // $ExpectError - untilEach( [ 1, 2, 3 ] ); // $ExpectError - untilEach( [ 1, 2, 3 ], isnan ); // $ExpectError - untilEach( [ 1, 2, 3 ], isnan, fcn, {}, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index c41d90c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isEven = require( '@stdlib/assert-is-even' ).isPrimitive; -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var untilEach = require( './../lib' ); - -function predicate( value ) { - return ( value !== value ); -} - -function log( value, index, collection ) { - console.log( '%s: %d', index, value ); - if ( isEven( index ) ) { - collection.shift(); - } else { - collection.push( index+1 ); - } -} - -var arr; -var j; -var i; - -arr = new Array( 100 ); -j = floor( randu()*arr.length ); -for ( i = 0; i < arr.length; i++ ) { - if ( i === j ) { - arr[ i ] = NaN; - } else { - arr[ i ] = i; - } -} - -untilEach( arr, predicate, log ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 19fe169..355b4df 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..10553a0 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function s(s,o,i,n){var d,l;if(!r(s))throw new TypeError(e("1YDAh",s));if(!t(o))throw new TypeError(e("1YD2H",o));if(!t(i))throw new TypeError(e("1YD3N",i));for(d=s.length,l=0;l=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b4d9451 --- /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 70a1888..0000000 --- a/test/test.js +++ /dev/null @@ -1,350 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var untilEach = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof untilEach, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {}, - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( value, noop, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a predicate function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a function to invoke', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], noop, value ); - }; - } -}); - -tape( 'if provided an empty collection, the function never invokes a provided function', function test( t ) { - var arr = []; - - function predicate() { - t.fail( 'should not be invoked' ); - } - - function foo() { - t.fail( 'should not be invoked' ); - } - - untilEach( arr, predicate, foo ); - - t.deepEqual( arr, [], 'expected result' ); - t.end(); -}); - -tape( 'the function returns the input collection', function test( t ) { - var arr; - var out; - - function predicate() { - t.pass( 'invoked predicated function' ); - return false; - } - - function foo() { - t.pass( 'invoked provided function' ); - } - - arr = [ 1, 2, 3 ]; - - out = untilEach( arr, predicate, foo ); - - t.strictEqual( out, arr, 'returns input collection' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array)', function test( t ) { - var arr; - var out; - - arr = [ 1, 2, NaN, 3 ]; - out = [ 0, 0, 0, 0 ]; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - untilEach( arr, predicate, copy ); - - t.deepEqual( out, [ 1, 2, 0, 0 ], 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array-like object)', function test( t ) { - var expected; - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = { - 'length': 4, - '0': 1, - '1': 2, - '2': NaN, - '3': 3 - }; - out = { - 'length': 4, - '0': 0, - '1': 0, - '2': 0, - '3': 0 - }; - - untilEach( arr, predicate, copy ); - - expected = { - 'length': 4, - '0': 1, - '1': 2, - '2': 0, - '3': 0 - }; - - t.deepEqual( out, expected, 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (typed array)', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = new Float64Array( [ 1.0, 2.0, NaN, 3.0 ] ); - out = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - untilEach( arr, predicate, copy ); - - t.strictEqual( out[ 0 ], 1.0, 'expected result' ); - t.strictEqual( out[ 1 ], 2.0, 'expected result' ); - t.strictEqual( out[ 2 ], 0.0, 'expected result' ); - t.strictEqual( out[ 3 ], 0.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx; - var arr; - - function predicate( value ) { - return ( value !== value ); - } - - function sum( value ) { - /* eslint-disable no-invalid-this */ - this.sum += value; - this.count += 1; - } - - ctx = { - 'sum': 0, - 'count': 0 - }; - arr = [ 1.0, 2.0, 3.0 ]; - - untilEach( arr, predicate, sum, ctx ); - - t.strictEqual( ctx.sum/ctx.count, 2.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function provides basic support for dynamic arrays', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index, collection ) { - out.push( value ); - if ( index === collection.length-1 && collection.length < 10 ) { - collection.push( index+2 ); - } - } - - arr = [ 1, 2, 3 ]; - out = []; - - untilEach( arr, predicate, copy ); - - t.deepEqual( arr, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.deepEqual( out, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.end(); -}); - -tape( 'the function does not skip empty elements', function test( t ) { - var expected; - var arr; - - function predicate( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - return false; - } - - function verify( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - } - - arr = [ 1, , , 4 ]; // eslint-disable-line no-sparse-arrays - expected = [ 1, void 0, void 0, 4 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); - -tape( 'the function invokes the predicate function and the function to apply with three arguments: value, index, collection', function test( t ) { - var indices; - var values; - var arr; - - function predicate( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - return false; - } - - function verify( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - } - - arr = [ 1, 2, 3, 4 ]; - values = [ 1, 2, 3, 4 ]; - indices = [ 0, 1, 2, 3 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); From 6a2c83ab1a35316b99f14e8923cc7ce3a636b9f9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 04:35:04 +0000 Subject: [PATCH 118/135] 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 846d968..42f57a7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,13 +56,13 @@ function untilEach( collection, predicate, fcn, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); + throw new TypeError( format( '1YDAh', collection ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '1YD2H', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '1YD3N', fcn ) ); } len = collection.length; i = 0; diff --git a/package.json b/package.json index b2bcfe3..8898c2a 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-collection": "^0.2.2", "@stdlib/assert-is-function": "^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 037eccbaa6473bc0444bcf074e794641a5ee4989 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 08:16:09 +0000 Subject: [PATCH 119/135] Remove files --- index.d.ts | 142 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4989 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 355b4df..0000000 --- a/index.d.ts +++ /dev/null @@ -1,142 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Checks whether an element in a collection passes a test. -* -* @returns boolean indicating whether an element in a collection passes a test -*/ -type NullaryPredicate = () => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @returns boolean indicating whether an element in a collection passes a test -*/ -type UnaryPredicate = ( value: T ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @returns boolean indicating whether an element in a collection passes a test -*/ -type BinaryPredicate = ( value: T, index: number ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type TernaryPredicate = ( value: T, index: number, collection: Collection ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Predicate = NullaryPredicate | UnaryPredicate | BinaryPredicate | TernaryPredicate; - -/** -* Function invoked for each collection element until test condition is true. -*/ -type Nullary = ( this: U ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -*/ -type Unary = ( this: U, value: T ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -*/ -type Binary = ( this: U, value: T, index: number ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Ternary = ( this: U, value: T, index: number, collection: Collection ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Until a test condition is true, invokes a function once for each element in a collection. -* -* ## Notes -* -* - When invoked, both the predicate function and the function to apply are provided three arguments: -* -* - `value`: collection value -* - `index`: collection index -* - `collection`: the input collection -* -* @param collection - input collection -* @param predicate - function which indicates whether to stop iterating over a collection -* @param fcn - function to invoke -* @param thisArg - execution context for the applied function -* @returns input collection -* -* @example -* function predicate( v, key, collection ) { -* return ( v !== v ); -* } -* -* function log( v, key, collection ) { -* console.log( '%s: %d', key, v ); -* } -* -* var arr = [ 1, 2, 3, 4, NaN, 5 ]; -* -* untilEach( arr, predicate, log ); -*/ -declare function untilEach( collection: Collection, predicate: Predicate, fcn: Callback, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = untilEach; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 10553a0..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function s(s,o,i,n){var d,l;if(!r(s))throw new TypeError(e("1YDAh",s));if(!t(o))throw new TypeError(e("1YD2H",o));if(!t(i))throw new TypeError(e("1YD3N",i));for(d=s.length,l=0;l - - - - - - Rollup Visualizer - - - -
- - - - - From 9bf399ea313c9daace62cf10fa83d2ee07a75ea8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 08:16:24 +0000 Subject: [PATCH 120/135] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 219 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 89 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 47 - docs/types/test.ts | 89 - examples/index.js | 53 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 83 - package.json | 62 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 350 -- 43 files changed, 4868 insertions(+), 4352 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index f33edda..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-10-01T03:27:22.903Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 038a13c..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/utils/until-each) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 4eecda2..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/utils/until-each) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 aa2a9b4..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: '35 11 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -295,7 +286,7 @@ untilEach( arr, predicate, log ); ## 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]. @@ -366,9 +357,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right +[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right/tree/esm -[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each +[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each/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 754724d..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var untilEach = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var sum; - var i; - - function predicate( v ) { - return isnan( v ); - } - - function fcn( v ) { - sum += v; - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - untilEach( arr, predicate, fcn ); - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::loop', function benchmark( b ) { - var sum; - var arr; - var i; - var j; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - j = 0; - while ( j < arr.length ) { - if ( isnan( arr[ j ] ) ) { - break; - } - sum += arr[ j ]; - j += 1; - } - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 5ae3876..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/utils/until-each" -%% click B href "https://github.com/stdlib-js/utils-until-each/tree/main" -%% click C href "https://github.com/stdlib-js/utils-until-each/tree/production" -%% click D href "https://github.com/stdlib-js/utils-until-each/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-until-each/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-until-each/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/until-each -[production-url]: https://github.com/stdlib-js/utils-until-each/tree/production -[deno-url]: https://github.com/stdlib-js/utils-until-each/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-until-each/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-until-each/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-until-each/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-until-each/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-until-each/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 4378886..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import untilEach from '../docs/types/index'; -export = untilEach; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 52eaf73..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var g=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var m=g(function(E,s){ -var h=require('@stdlib/assert-is-collection/dist'),n=require('@stdlib/assert-is-function/dist'),i=require('@stdlib/error-tools-fmtprodmsg/dist');function w(r,e,a,v){var t,u;if(!h(r))throw new TypeError(i('1YDAh',r));if(!n(e))throw new TypeError(i('1YD2H',e));if(!n(a))throw new TypeError(i('1YD3N',a));for(t=r.length,u=0;u function predicate( v ) { return v !== v; }; - > function logger( v, i ) { console.log( '%s: %d', i, v ); }; - > var arr = [ 1, 2, 3, 4, NaN, 5 ]; - > {{alias}}( arr, predicate, logger ) - 0: 1 - 1: 2 - 2: 3 - 3: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4833283..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,89 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 untilEach = require( './index' ); - -/** -* Test function. -* -* @param v - value -* @param index - index -*/ -function fcn( v: number, index: number ): void { - if ( v !== v ) { - throw new Error( 'beep' ); - } - if ( index !== index ) { - throw new Error( 'beep' ); - } -} - -/** -* Test function. -* -* @param v - value -* @returns result -*/ -function isnan( v: number ): boolean { - return ( v !== v ); -} - - -// TESTS // - -// The function returns the input collection... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, fcn ); // $ExpectType Collection - untilEach( [ -1, 1, 2 ], isnan, fcn, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - untilEach( 2, isnan, fcn ); // $ExpectError - untilEach( false, isnan, fcn ); // $ExpectError - untilEach( true, isnan, fcn ); // $ExpectError - untilEach( {}, isnan, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], 2, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], false, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], true, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], 'abc', fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], {}, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], [], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, 2 ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, false ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, true ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, 'abc' ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, {} ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - untilEach(); // $ExpectError - untilEach( [ 1, 2, 3 ] ); // $ExpectError - untilEach( [ 1, 2, 3 ], isnan ); // $ExpectError - untilEach( [ 1, 2, 3 ], isnan, fcn, {}, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index c41d90c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isEven = require( '@stdlib/assert-is-even' ).isPrimitive; -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var untilEach = require( './../lib' ); - -function predicate( value ) { - return ( value !== value ); -} - -function log( value, index, collection ) { - console.log( '%s: %d', index, value ); - if ( isEven( index ) ) { - collection.shift(); - } else { - collection.push( index+1 ); - } -} - -var arr; -var j; -var i; - -arr = new Array( 100 ); -j = floor( randu()*arr.length ); -for ( i = 0; i < arr.length; i++ ) { - if ( i === j ) { - arr[ i ] = NaN; - } else { - arr[ i ] = i; - } -} - -untilEach( arr, predicate, log ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 19fe169..355b4df 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..10553a0 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function s(s,o,i,n){var d,l;if(!r(s))throw new TypeError(e("1YDAh",s));if(!t(o))throw new TypeError(e("1YD2H",o));if(!t(i))throw new TypeError(e("1YD3N",i));for(d=s.length,l=0;l=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b4d9451 --- /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 70a1888..0000000 --- a/test/test.js +++ /dev/null @@ -1,350 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var untilEach = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof untilEach, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {}, - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( value, noop, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a predicate function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a function to invoke', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], noop, value ); - }; - } -}); - -tape( 'if provided an empty collection, the function never invokes a provided function', function test( t ) { - var arr = []; - - function predicate() { - t.fail( 'should not be invoked' ); - } - - function foo() { - t.fail( 'should not be invoked' ); - } - - untilEach( arr, predicate, foo ); - - t.deepEqual( arr, [], 'expected result' ); - t.end(); -}); - -tape( 'the function returns the input collection', function test( t ) { - var arr; - var out; - - function predicate() { - t.pass( 'invoked predicated function' ); - return false; - } - - function foo() { - t.pass( 'invoked provided function' ); - } - - arr = [ 1, 2, 3 ]; - - out = untilEach( arr, predicate, foo ); - - t.strictEqual( out, arr, 'returns input collection' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array)', function test( t ) { - var arr; - var out; - - arr = [ 1, 2, NaN, 3 ]; - out = [ 0, 0, 0, 0 ]; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - untilEach( arr, predicate, copy ); - - t.deepEqual( out, [ 1, 2, 0, 0 ], 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array-like object)', function test( t ) { - var expected; - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = { - 'length': 4, - '0': 1, - '1': 2, - '2': NaN, - '3': 3 - }; - out = { - 'length': 4, - '0': 0, - '1': 0, - '2': 0, - '3': 0 - }; - - untilEach( arr, predicate, copy ); - - expected = { - 'length': 4, - '0': 1, - '1': 2, - '2': 0, - '3': 0 - }; - - t.deepEqual( out, expected, 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (typed array)', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = new Float64Array( [ 1.0, 2.0, NaN, 3.0 ] ); - out = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - untilEach( arr, predicate, copy ); - - t.strictEqual( out[ 0 ], 1.0, 'expected result' ); - t.strictEqual( out[ 1 ], 2.0, 'expected result' ); - t.strictEqual( out[ 2 ], 0.0, 'expected result' ); - t.strictEqual( out[ 3 ], 0.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx; - var arr; - - function predicate( value ) { - return ( value !== value ); - } - - function sum( value ) { - /* eslint-disable no-invalid-this */ - this.sum += value; - this.count += 1; - } - - ctx = { - 'sum': 0, - 'count': 0 - }; - arr = [ 1.0, 2.0, 3.0 ]; - - untilEach( arr, predicate, sum, ctx ); - - t.strictEqual( ctx.sum/ctx.count, 2.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function provides basic support for dynamic arrays', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index, collection ) { - out.push( value ); - if ( index === collection.length-1 && collection.length < 10 ) { - collection.push( index+2 ); - } - } - - arr = [ 1, 2, 3 ]; - out = []; - - untilEach( arr, predicate, copy ); - - t.deepEqual( arr, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.deepEqual( out, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.end(); -}); - -tape( 'the function does not skip empty elements', function test( t ) { - var expected; - var arr; - - function predicate( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - return false; - } - - function verify( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - } - - arr = [ 1, , , 4 ]; // eslint-disable-line no-sparse-arrays - expected = [ 1, void 0, void 0, 4 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); - -tape( 'the function invokes the predicate function and the function to apply with three arguments: value, index, collection', function test( t ) { - var indices; - var values; - var arr; - - function predicate( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - return false; - } - - function verify( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - } - - arr = [ 1, 2, 3, 4 ]; - values = [ 1, 2, 3, 4 ]; - indices = [ 0, 1, 2, 3 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); From fed93ca03432763c8e36794cf05534823f1f4a79 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 04:32:53 +0000 Subject: [PATCH 121/135] 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 846d968..42f57a7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,13 +56,13 @@ function untilEach( collection, predicate, fcn, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); + throw new TypeError( format( '1YDAh', collection ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '1YD2H', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '1YD3N', fcn ) ); } len = collection.length; i = 0; diff --git a/package.json b/package.json index b2bcfe3..8898c2a 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-collection": "^0.2.2", "@stdlib/assert-is-function": "^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 9dfa696fc77094d6a281487657a19ed2571309d8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 07:52:10 +0000 Subject: [PATCH 122/135] Remove files --- index.d.ts | 142 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4989 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 355b4df..0000000 --- a/index.d.ts +++ /dev/null @@ -1,142 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Checks whether an element in a collection passes a test. -* -* @returns boolean indicating whether an element in a collection passes a test -*/ -type NullaryPredicate = () => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @returns boolean indicating whether an element in a collection passes a test -*/ -type UnaryPredicate = ( value: T ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @returns boolean indicating whether an element in a collection passes a test -*/ -type BinaryPredicate = ( value: T, index: number ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type TernaryPredicate = ( value: T, index: number, collection: Collection ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Predicate = NullaryPredicate | UnaryPredicate | BinaryPredicate | TernaryPredicate; - -/** -* Function invoked for each collection element until test condition is true. -*/ -type Nullary = ( this: U ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -*/ -type Unary = ( this: U, value: T ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -*/ -type Binary = ( this: U, value: T, index: number ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Ternary = ( this: U, value: T, index: number, collection: Collection ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Until a test condition is true, invokes a function once for each element in a collection. -* -* ## Notes -* -* - When invoked, both the predicate function and the function to apply are provided three arguments: -* -* - `value`: collection value -* - `index`: collection index -* - `collection`: the input collection -* -* @param collection - input collection -* @param predicate - function which indicates whether to stop iterating over a collection -* @param fcn - function to invoke -* @param thisArg - execution context for the applied function -* @returns input collection -* -* @example -* function predicate( v, key, collection ) { -* return ( v !== v ); -* } -* -* function log( v, key, collection ) { -* console.log( '%s: %d', key, v ); -* } -* -* var arr = [ 1, 2, 3, 4, NaN, 5 ]; -* -* untilEach( arr, predicate, log ); -*/ -declare function untilEach( collection: Collection, predicate: Predicate, fcn: Callback, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = untilEach; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 10553a0..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function s(s,o,i,n){var d,l;if(!r(s))throw new TypeError(e("1YDAh",s));if(!t(o))throw new TypeError(e("1YD2H",o));if(!t(i))throw new TypeError(e("1YD3N",i));for(d=s.length,l=0;l - - - - - - Rollup Visualizer - - - -
- - - - - From 20302bcb6fdf19ac4d6578341a890a2a72bc50d1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 07:52:23 +0000 Subject: [PATCH 123/135] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 219 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 89 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 47 - docs/types/test.ts | 89 - examples/index.js | 53 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 83 - package.json | 62 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 350 -- 43 files changed, 4868 insertions(+), 4352 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 35d5b50..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-11-01T03:29:50.191Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 038a13c..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/utils/until-each) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 4eecda2..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/utils/until-each) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 aa2a9b4..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: '35 11 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -295,7 +286,7 @@ untilEach( arr, predicate, log ); ## 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]. @@ -366,9 +357,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right +[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right/tree/esm -[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each +[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each/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 754724d..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var untilEach = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var sum; - var i; - - function predicate( v ) { - return isnan( v ); - } - - function fcn( v ) { - sum += v; - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - untilEach( arr, predicate, fcn ); - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::loop', function benchmark( b ) { - var sum; - var arr; - var i; - var j; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - j = 0; - while ( j < arr.length ) { - if ( isnan( arr[ j ] ) ) { - break; - } - sum += arr[ j ]; - j += 1; - } - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 5ae3876..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/utils/until-each" -%% click B href "https://github.com/stdlib-js/utils-until-each/tree/main" -%% click C href "https://github.com/stdlib-js/utils-until-each/tree/production" -%% click D href "https://github.com/stdlib-js/utils-until-each/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-until-each/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-until-each/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/until-each -[production-url]: https://github.com/stdlib-js/utils-until-each/tree/production -[deno-url]: https://github.com/stdlib-js/utils-until-each/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-until-each/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-until-each/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-until-each/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-until-each/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-until-each/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 4378886..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import untilEach from '../docs/types/index'; -export = untilEach; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 52eaf73..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var g=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var m=g(function(E,s){ -var h=require('@stdlib/assert-is-collection/dist'),n=require('@stdlib/assert-is-function/dist'),i=require('@stdlib/error-tools-fmtprodmsg/dist');function w(r,e,a,v){var t,u;if(!h(r))throw new TypeError(i('1YDAh',r));if(!n(e))throw new TypeError(i('1YD2H',e));if(!n(a))throw new TypeError(i('1YD3N',a));for(t=r.length,u=0;u function predicate( v ) { return v !== v; }; - > function logger( v, i ) { console.log( '%s: %d', i, v ); }; - > var arr = [ 1, 2, 3, 4, NaN, 5 ]; - > {{alias}}( arr, predicate, logger ) - 0: 1 - 1: 2 - 2: 3 - 3: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4833283..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,89 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 untilEach = require( './index' ); - -/** -* Test function. -* -* @param v - value -* @param index - index -*/ -function fcn( v: number, index: number ): void { - if ( v !== v ) { - throw new Error( 'beep' ); - } - if ( index !== index ) { - throw new Error( 'beep' ); - } -} - -/** -* Test function. -* -* @param v - value -* @returns result -*/ -function isnan( v: number ): boolean { - return ( v !== v ); -} - - -// TESTS // - -// The function returns the input collection... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, fcn ); // $ExpectType Collection - untilEach( [ -1, 1, 2 ], isnan, fcn, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - untilEach( 2, isnan, fcn ); // $ExpectError - untilEach( false, isnan, fcn ); // $ExpectError - untilEach( true, isnan, fcn ); // $ExpectError - untilEach( {}, isnan, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], 2, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], false, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], true, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], 'abc', fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], {}, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], [], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, 2 ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, false ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, true ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, 'abc' ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, {} ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - untilEach(); // $ExpectError - untilEach( [ 1, 2, 3 ] ); // $ExpectError - untilEach( [ 1, 2, 3 ], isnan ); // $ExpectError - untilEach( [ 1, 2, 3 ], isnan, fcn, {}, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index c41d90c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isEven = require( '@stdlib/assert-is-even' ).isPrimitive; -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var untilEach = require( './../lib' ); - -function predicate( value ) { - return ( value !== value ); -} - -function log( value, index, collection ) { - console.log( '%s: %d', index, value ); - if ( isEven( index ) ) { - collection.shift(); - } else { - collection.push( index+1 ); - } -} - -var arr; -var j; -var i; - -arr = new Array( 100 ); -j = floor( randu()*arr.length ); -for ( i = 0; i < arr.length; i++ ) { - if ( i === j ) { - arr[ i ] = NaN; - } else { - arr[ i ] = i; - } -} - -untilEach( arr, predicate, log ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 19fe169..355b4df 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..10553a0 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function s(s,o,i,n){var d,l;if(!r(s))throw new TypeError(e("1YDAh",s));if(!t(o))throw new TypeError(e("1YD2H",o));if(!t(i))throw new TypeError(e("1YD3N",i));for(d=s.length,l=0;l=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b4d9451 --- /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 70a1888..0000000 --- a/test/test.js +++ /dev/null @@ -1,350 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var untilEach = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof untilEach, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {}, - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( value, noop, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a predicate function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a function to invoke', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], noop, value ); - }; - } -}); - -tape( 'if provided an empty collection, the function never invokes a provided function', function test( t ) { - var arr = []; - - function predicate() { - t.fail( 'should not be invoked' ); - } - - function foo() { - t.fail( 'should not be invoked' ); - } - - untilEach( arr, predicate, foo ); - - t.deepEqual( arr, [], 'expected result' ); - t.end(); -}); - -tape( 'the function returns the input collection', function test( t ) { - var arr; - var out; - - function predicate() { - t.pass( 'invoked predicated function' ); - return false; - } - - function foo() { - t.pass( 'invoked provided function' ); - } - - arr = [ 1, 2, 3 ]; - - out = untilEach( arr, predicate, foo ); - - t.strictEqual( out, arr, 'returns input collection' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array)', function test( t ) { - var arr; - var out; - - arr = [ 1, 2, NaN, 3 ]; - out = [ 0, 0, 0, 0 ]; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - untilEach( arr, predicate, copy ); - - t.deepEqual( out, [ 1, 2, 0, 0 ], 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array-like object)', function test( t ) { - var expected; - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = { - 'length': 4, - '0': 1, - '1': 2, - '2': NaN, - '3': 3 - }; - out = { - 'length': 4, - '0': 0, - '1': 0, - '2': 0, - '3': 0 - }; - - untilEach( arr, predicate, copy ); - - expected = { - 'length': 4, - '0': 1, - '1': 2, - '2': 0, - '3': 0 - }; - - t.deepEqual( out, expected, 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (typed array)', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = new Float64Array( [ 1.0, 2.0, NaN, 3.0 ] ); - out = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - untilEach( arr, predicate, copy ); - - t.strictEqual( out[ 0 ], 1.0, 'expected result' ); - t.strictEqual( out[ 1 ], 2.0, 'expected result' ); - t.strictEqual( out[ 2 ], 0.0, 'expected result' ); - t.strictEqual( out[ 3 ], 0.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx; - var arr; - - function predicate( value ) { - return ( value !== value ); - } - - function sum( value ) { - /* eslint-disable no-invalid-this */ - this.sum += value; - this.count += 1; - } - - ctx = { - 'sum': 0, - 'count': 0 - }; - arr = [ 1.0, 2.0, 3.0 ]; - - untilEach( arr, predicate, sum, ctx ); - - t.strictEqual( ctx.sum/ctx.count, 2.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function provides basic support for dynamic arrays', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index, collection ) { - out.push( value ); - if ( index === collection.length-1 && collection.length < 10 ) { - collection.push( index+2 ); - } - } - - arr = [ 1, 2, 3 ]; - out = []; - - untilEach( arr, predicate, copy ); - - t.deepEqual( arr, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.deepEqual( out, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.end(); -}); - -tape( 'the function does not skip empty elements', function test( t ) { - var expected; - var arr; - - function predicate( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - return false; - } - - function verify( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - } - - arr = [ 1, , , 4 ]; // eslint-disable-line no-sparse-arrays - expected = [ 1, void 0, void 0, 4 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); - -tape( 'the function invokes the predicate function and the function to apply with three arguments: value, index, collection', function test( t ) { - var indices; - var values; - var arr; - - function predicate( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - return false; - } - - function verify( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - } - - arr = [ 1, 2, 3, 4 ]; - values = [ 1, 2, 3, 4 ]; - indices = [ 0, 1, 2, 3 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); From f48dc31df9a5df0215829f627533f17a6f506930 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 04:46:49 +0000 Subject: [PATCH 124/135] 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 846d968..42f57a7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,13 +56,13 @@ function untilEach( collection, predicate, fcn, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); + throw new TypeError( format( '1YDAh', collection ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '1YD2H', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '1YD3N', fcn ) ); } len = collection.length; i = 0; diff --git a/package.json b/package.json index 18396cb..5239c2e 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-collection": "^0.2.2", "@stdlib/assert-is-function": "^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 ccd14be780da75352791652cb5f20f123f94d343 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 08:19:43 +0000 Subject: [PATCH 125/135] Remove files --- index.d.ts | 142 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4989 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 355b4df..0000000 --- a/index.d.ts +++ /dev/null @@ -1,142 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Checks whether an element in a collection passes a test. -* -* @returns boolean indicating whether an element in a collection passes a test -*/ -type NullaryPredicate = () => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @returns boolean indicating whether an element in a collection passes a test -*/ -type UnaryPredicate = ( value: T ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @returns boolean indicating whether an element in a collection passes a test -*/ -type BinaryPredicate = ( value: T, index: number ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type TernaryPredicate = ( value: T, index: number, collection: Collection ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Predicate = NullaryPredicate | UnaryPredicate | BinaryPredicate | TernaryPredicate; - -/** -* Function invoked for each collection element until test condition is true. -*/ -type Nullary = ( this: U ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -*/ -type Unary = ( this: U, value: T ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -*/ -type Binary = ( this: U, value: T, index: number ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Ternary = ( this: U, value: T, index: number, collection: Collection ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Until a test condition is true, invokes a function once for each element in a collection. -* -* ## Notes -* -* - When invoked, both the predicate function and the function to apply are provided three arguments: -* -* - `value`: collection value -* - `index`: collection index -* - `collection`: the input collection -* -* @param collection - input collection -* @param predicate - function which indicates whether to stop iterating over a collection -* @param fcn - function to invoke -* @param thisArg - execution context for the applied function -* @returns input collection -* -* @example -* function predicate( v, key, collection ) { -* return ( v !== v ); -* } -* -* function log( v, key, collection ) { -* console.log( '%s: %d', key, v ); -* } -* -* var arr = [ 1, 2, 3, 4, NaN, 5 ]; -* -* untilEach( arr, predicate, log ); -*/ -declare function untilEach( collection: Collection, predicate: Predicate, fcn: Callback, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = untilEach; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 10553a0..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function s(s,o,i,n){var d,l;if(!r(s))throw new TypeError(e("1YDAh",s));if(!t(o))throw new TypeError(e("1YD2H",o));if(!t(i))throw new TypeError(e("1YD3N",i));for(d=s.length,l=0;l - - - - - - Rollup Visualizer - - - -
- - - - - From c05c04802fda2210ebc72ed05a3811636ff31d37 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 08:19:59 +0000 Subject: [PATCH 126/135] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 219 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 89 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 47 - docs/types/test.ts | 89 - examples/index.js | 53 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 83 - package.json | 62 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 350 -- 44 files changed, 4868 insertions(+), 4457 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 2d9e015..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-12-01T03:34:40.065Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 038a13c..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/utils/until-each) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 4eecda2..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/utils/until-each) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 aa2a9b4..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: '35 11 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -295,7 +286,7 @@ untilEach( arr, predicate, log ); ## 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]. @@ -366,9 +357,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right +[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right/tree/esm -[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each +[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each/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 754724d..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var untilEach = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var sum; - var i; - - function predicate( v ) { - return isnan( v ); - } - - function fcn( v ) { - sum += v; - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - untilEach( arr, predicate, fcn ); - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::loop', function benchmark( b ) { - var sum; - var arr; - var i; - var j; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - j = 0; - while ( j < arr.length ) { - if ( isnan( arr[ j ] ) ) { - break; - } - sum += arr[ j ]; - j += 1; - } - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 5ae3876..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/utils/until-each" -%% click B href "https://github.com/stdlib-js/utils-until-each/tree/main" -%% click C href "https://github.com/stdlib-js/utils-until-each/tree/production" -%% click D href "https://github.com/stdlib-js/utils-until-each/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-until-each/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-until-each/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/until-each -[production-url]: https://github.com/stdlib-js/utils-until-each/tree/production -[deno-url]: https://github.com/stdlib-js/utils-until-each/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-until-each/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-until-each/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-until-each/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-until-each/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-until-each/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 4378886..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import untilEach from '../docs/types/index'; -export = untilEach; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 52eaf73..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var g=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var m=g(function(E,s){ -var h=require('@stdlib/assert-is-collection/dist'),n=require('@stdlib/assert-is-function/dist'),i=require('@stdlib/error-tools-fmtprodmsg/dist');function w(r,e,a,v){var t,u;if(!h(r))throw new TypeError(i('1YDAh',r));if(!n(e))throw new TypeError(i('1YD2H',e));if(!n(a))throw new TypeError(i('1YD3N',a));for(t=r.length,u=0;u function predicate( v ) { return v !== v; }; - > function logger( v, i ) { console.log( '%s: %d', i, v ); }; - > var arr = [ 1, 2, 3, 4, NaN, 5 ]; - > {{alias}}( arr, predicate, logger ) - 0: 1 - 1: 2 - 2: 3 - 3: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4833283..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,89 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 untilEach = require( './index' ); - -/** -* Test function. -* -* @param v - value -* @param index - index -*/ -function fcn( v: number, index: number ): void { - if ( v !== v ) { - throw new Error( 'beep' ); - } - if ( index !== index ) { - throw new Error( 'beep' ); - } -} - -/** -* Test function. -* -* @param v - value -* @returns result -*/ -function isnan( v: number ): boolean { - return ( v !== v ); -} - - -// TESTS // - -// The function returns the input collection... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, fcn ); // $ExpectType Collection - untilEach( [ -1, 1, 2 ], isnan, fcn, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - untilEach( 2, isnan, fcn ); // $ExpectError - untilEach( false, isnan, fcn ); // $ExpectError - untilEach( true, isnan, fcn ); // $ExpectError - untilEach( {}, isnan, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], 2, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], false, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], true, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], 'abc', fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], {}, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], [], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, 2 ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, false ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, true ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, 'abc' ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, {} ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - untilEach(); // $ExpectError - untilEach( [ 1, 2, 3 ] ); // $ExpectError - untilEach( [ 1, 2, 3 ], isnan ); // $ExpectError - untilEach( [ 1, 2, 3 ], isnan, fcn, {}, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index c41d90c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isEven = require( '@stdlib/assert-is-even' ).isPrimitive; -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var untilEach = require( './../lib' ); - -function predicate( value ) { - return ( value !== value ); -} - -function log( value, index, collection ) { - console.log( '%s: %d', index, value ); - if ( isEven( index ) ) { - collection.shift(); - } else { - collection.push( index+1 ); - } -} - -var arr; -var j; -var i; - -arr = new Array( 100 ); -j = floor( randu()*arr.length ); -for ( i = 0; i < arr.length; i++ ) { - if ( i === j ) { - arr[ i ] = NaN; - } else { - arr[ i ] = i; - } -} - -untilEach( arr, predicate, log ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 19fe169..355b4df 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..10553a0 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function s(s,o,i,n){var d,l;if(!r(s))throw new TypeError(e("1YDAh",s));if(!t(o))throw new TypeError(e("1YD2H",o));if(!t(i))throw new TypeError(e("1YD3N",i));for(d=s.length,l=0;l=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b4d9451 --- /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 70a1888..0000000 --- a/test/test.js +++ /dev/null @@ -1,350 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var untilEach = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof untilEach, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {}, - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( value, noop, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a predicate function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a function to invoke', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], noop, value ); - }; - } -}); - -tape( 'if provided an empty collection, the function never invokes a provided function', function test( t ) { - var arr = []; - - function predicate() { - t.fail( 'should not be invoked' ); - } - - function foo() { - t.fail( 'should not be invoked' ); - } - - untilEach( arr, predicate, foo ); - - t.deepEqual( arr, [], 'expected result' ); - t.end(); -}); - -tape( 'the function returns the input collection', function test( t ) { - var arr; - var out; - - function predicate() { - t.pass( 'invoked predicated function' ); - return false; - } - - function foo() { - t.pass( 'invoked provided function' ); - } - - arr = [ 1, 2, 3 ]; - - out = untilEach( arr, predicate, foo ); - - t.strictEqual( out, arr, 'returns input collection' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array)', function test( t ) { - var arr; - var out; - - arr = [ 1, 2, NaN, 3 ]; - out = [ 0, 0, 0, 0 ]; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - untilEach( arr, predicate, copy ); - - t.deepEqual( out, [ 1, 2, 0, 0 ], 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array-like object)', function test( t ) { - var expected; - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = { - 'length': 4, - '0': 1, - '1': 2, - '2': NaN, - '3': 3 - }; - out = { - 'length': 4, - '0': 0, - '1': 0, - '2': 0, - '3': 0 - }; - - untilEach( arr, predicate, copy ); - - expected = { - 'length': 4, - '0': 1, - '1': 2, - '2': 0, - '3': 0 - }; - - t.deepEqual( out, expected, 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (typed array)', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = new Float64Array( [ 1.0, 2.0, NaN, 3.0 ] ); - out = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - untilEach( arr, predicate, copy ); - - t.strictEqual( out[ 0 ], 1.0, 'expected result' ); - t.strictEqual( out[ 1 ], 2.0, 'expected result' ); - t.strictEqual( out[ 2 ], 0.0, 'expected result' ); - t.strictEqual( out[ 3 ], 0.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx; - var arr; - - function predicate( value ) { - return ( value !== value ); - } - - function sum( value ) { - /* eslint-disable no-invalid-this */ - this.sum += value; - this.count += 1; - } - - ctx = { - 'sum': 0, - 'count': 0 - }; - arr = [ 1.0, 2.0, 3.0 ]; - - untilEach( arr, predicate, sum, ctx ); - - t.strictEqual( ctx.sum/ctx.count, 2.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function provides basic support for dynamic arrays', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index, collection ) { - out.push( value ); - if ( index === collection.length-1 && collection.length < 10 ) { - collection.push( index+2 ); - } - } - - arr = [ 1, 2, 3 ]; - out = []; - - untilEach( arr, predicate, copy ); - - t.deepEqual( arr, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.deepEqual( out, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.end(); -}); - -tape( 'the function does not skip empty elements', function test( t ) { - var expected; - var arr; - - function predicate( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - return false; - } - - function verify( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - } - - arr = [ 1, , , 4 ]; // eslint-disable-line no-sparse-arrays - expected = [ 1, void 0, void 0, 4 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); - -tape( 'the function invokes the predicate function and the function to apply with three arguments: value, index, collection', function test( t ) { - var indices; - var values; - var arr; - - function predicate( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - return false; - } - - function verify( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - } - - arr = [ 1, 2, 3, 4 ]; - values = [ 1, 2, 3, 4 ]; - indices = [ 0, 1, 2, 3 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); From 11495e6adb89eef392f94f3d8833be57f42a0adc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Dec 2024 03:35:16 +0000 Subject: [PATCH 127/135] 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 846d968..42f57a7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,13 +56,13 @@ function untilEach( collection, predicate, fcn, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); + throw new TypeError( format( '1YDAh', collection ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '1YD2H', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '1YD3N', fcn ) ); } len = collection.length; i = 0; diff --git a/package.json b/package.json index 18396cb..5239c2e 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-collection": "^0.2.2", "@stdlib/assert-is-function": "^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 6b60026bf7dd8c922935b882eb2a68a564394fe5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Dec 2024 04:47:53 +0000 Subject: [PATCH 128/135] Remove files --- index.d.ts | 142 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4989 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 355b4df..0000000 --- a/index.d.ts +++ /dev/null @@ -1,142 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Checks whether an element in a collection passes a test. -* -* @returns boolean indicating whether an element in a collection passes a test -*/ -type NullaryPredicate = () => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @returns boolean indicating whether an element in a collection passes a test -*/ -type UnaryPredicate = ( value: T ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @returns boolean indicating whether an element in a collection passes a test -*/ -type BinaryPredicate = ( value: T, index: number ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type TernaryPredicate = ( value: T, index: number, collection: Collection ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Predicate = NullaryPredicate | UnaryPredicate | BinaryPredicate | TernaryPredicate; - -/** -* Function invoked for each collection element until test condition is true. -*/ -type Nullary = ( this: U ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -*/ -type Unary = ( this: U, value: T ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -*/ -type Binary = ( this: U, value: T, index: number ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Ternary = ( this: U, value: T, index: number, collection: Collection ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Until a test condition is true, invokes a function once for each element in a collection. -* -* ## Notes -* -* - When invoked, both the predicate function and the function to apply are provided three arguments: -* -* - `value`: collection value -* - `index`: collection index -* - `collection`: the input collection -* -* @param collection - input collection -* @param predicate - function which indicates whether to stop iterating over a collection -* @param fcn - function to invoke -* @param thisArg - execution context for the applied function -* @returns input collection -* -* @example -* function predicate( v, key, collection ) { -* return ( v !== v ); -* } -* -* function log( v, key, collection ) { -* console.log( '%s: %d', key, v ); -* } -* -* var arr = [ 1, 2, 3, 4, NaN, 5 ]; -* -* untilEach( arr, predicate, log ); -*/ -declare function untilEach( collection: Collection, predicate: Predicate, fcn: Callback, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = untilEach; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 10553a0..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function s(s,o,i,n){var d,l;if(!r(s))throw new TypeError(e("1YDAh",s));if(!t(o))throw new TypeError(e("1YD2H",o));if(!t(i))throw new TypeError(e("1YD3N",i));for(d=s.length,l=0;l - - - - - - Rollup Visualizer - - - -
- - - - - From 3700bf9cb3d82787a04360afdf4d96a2611d54c9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Dec 2024 04:48:06 +0000 Subject: [PATCH 129/135] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 219 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 89 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 47 - docs/types/test.ts | 89 - examples/index.js | 53 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 83 - package.json | 62 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 350 -- 44 files changed, 4868 insertions(+), 4457 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0779e8a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 39aa6cd..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-12-30T03:02:18.851Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 038a13c..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/utils/until-each) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 4eecda2..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/utils/until-each) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 aa2a9b4..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: '35 11 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -295,7 +286,7 @@ untilEach( arr, predicate, log ); ## 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]. @@ -366,9 +357,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right +[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right/tree/esm -[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each +[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each/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 754724d..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var untilEach = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var sum; - var i; - - function predicate( v ) { - return isnan( v ); - } - - function fcn( v ) { - sum += v; - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - untilEach( arr, predicate, fcn ); - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::loop', function benchmark( b ) { - var sum; - var arr; - var i; - var j; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - j = 0; - while ( j < arr.length ) { - if ( isnan( arr[ j ] ) ) { - break; - } - sum += arr[ j ]; - j += 1; - } - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 5ae3876..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/utils/until-each" -%% click B href "https://github.com/stdlib-js/utils-until-each/tree/main" -%% click C href "https://github.com/stdlib-js/utils-until-each/tree/production" -%% click D href "https://github.com/stdlib-js/utils-until-each/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-until-each/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-until-each/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/until-each -[production-url]: https://github.com/stdlib-js/utils-until-each/tree/production -[deno-url]: https://github.com/stdlib-js/utils-until-each/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-until-each/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-until-each/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-until-each/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-until-each/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-until-each/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 4378886..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import untilEach from '../docs/types/index'; -export = untilEach; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 52eaf73..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var g=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var m=g(function(E,s){ -var h=require('@stdlib/assert-is-collection/dist'),n=require('@stdlib/assert-is-function/dist'),i=require('@stdlib/error-tools-fmtprodmsg/dist');function w(r,e,a,v){var t,u;if(!h(r))throw new TypeError(i('1YDAh',r));if(!n(e))throw new TypeError(i('1YD2H',e));if(!n(a))throw new TypeError(i('1YD3N',a));for(t=r.length,u=0;u function predicate( v ) { return v !== v; }; - > function logger( v, i ) { console.log( '%s: %d', i, v ); }; - > var arr = [ 1, 2, 3, 4, NaN, 5 ]; - > {{alias}}( arr, predicate, logger ) - 0: 1 - 1: 2 - 2: 3 - 3: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4833283..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,89 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 untilEach = require( './index' ); - -/** -* Test function. -* -* @param v - value -* @param index - index -*/ -function fcn( v: number, index: number ): void { - if ( v !== v ) { - throw new Error( 'beep' ); - } - if ( index !== index ) { - throw new Error( 'beep' ); - } -} - -/** -* Test function. -* -* @param v - value -* @returns result -*/ -function isnan( v: number ): boolean { - return ( v !== v ); -} - - -// TESTS // - -// The function returns the input collection... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, fcn ); // $ExpectType Collection - untilEach( [ -1, 1, 2 ], isnan, fcn, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - untilEach( 2, isnan, fcn ); // $ExpectError - untilEach( false, isnan, fcn ); // $ExpectError - untilEach( true, isnan, fcn ); // $ExpectError - untilEach( {}, isnan, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], 2, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], false, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], true, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], 'abc', fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], {}, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], [], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, 2 ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, false ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, true ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, 'abc' ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, {} ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - untilEach(); // $ExpectError - untilEach( [ 1, 2, 3 ] ); // $ExpectError - untilEach( [ 1, 2, 3 ], isnan ); // $ExpectError - untilEach( [ 1, 2, 3 ], isnan, fcn, {}, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index c41d90c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isEven = require( '@stdlib/assert-is-even' ).isPrimitive; -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var untilEach = require( './../lib' ); - -function predicate( value ) { - return ( value !== value ); -} - -function log( value, index, collection ) { - console.log( '%s: %d', index, value ); - if ( isEven( index ) ) { - collection.shift(); - } else { - collection.push( index+1 ); - } -} - -var arr; -var j; -var i; - -arr = new Array( 100 ); -j = floor( randu()*arr.length ); -for ( i = 0; i < arr.length; i++ ) { - if ( i === j ) { - arr[ i ] = NaN; - } else { - arr[ i ] = i; - } -} - -untilEach( arr, predicate, log ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 19fe169..355b4df 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..10553a0 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function s(s,o,i,n){var d,l;if(!r(s))throw new TypeError(e("1YDAh",s));if(!t(o))throw new TypeError(e("1YD2H",o));if(!t(i))throw new TypeError(e("1YD3N",i));for(d=s.length,l=0;l=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b4d9451 --- /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 70a1888..0000000 --- a/test/test.js +++ /dev/null @@ -1,350 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var untilEach = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof untilEach, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {}, - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( value, noop, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a predicate function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a function to invoke', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], noop, value ); - }; - } -}); - -tape( 'if provided an empty collection, the function never invokes a provided function', function test( t ) { - var arr = []; - - function predicate() { - t.fail( 'should not be invoked' ); - } - - function foo() { - t.fail( 'should not be invoked' ); - } - - untilEach( arr, predicate, foo ); - - t.deepEqual( arr, [], 'expected result' ); - t.end(); -}); - -tape( 'the function returns the input collection', function test( t ) { - var arr; - var out; - - function predicate() { - t.pass( 'invoked predicated function' ); - return false; - } - - function foo() { - t.pass( 'invoked provided function' ); - } - - arr = [ 1, 2, 3 ]; - - out = untilEach( arr, predicate, foo ); - - t.strictEqual( out, arr, 'returns input collection' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array)', function test( t ) { - var arr; - var out; - - arr = [ 1, 2, NaN, 3 ]; - out = [ 0, 0, 0, 0 ]; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - untilEach( arr, predicate, copy ); - - t.deepEqual( out, [ 1, 2, 0, 0 ], 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array-like object)', function test( t ) { - var expected; - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = { - 'length': 4, - '0': 1, - '1': 2, - '2': NaN, - '3': 3 - }; - out = { - 'length': 4, - '0': 0, - '1': 0, - '2': 0, - '3': 0 - }; - - untilEach( arr, predicate, copy ); - - expected = { - 'length': 4, - '0': 1, - '1': 2, - '2': 0, - '3': 0 - }; - - t.deepEqual( out, expected, 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (typed array)', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = new Float64Array( [ 1.0, 2.0, NaN, 3.0 ] ); - out = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - untilEach( arr, predicate, copy ); - - t.strictEqual( out[ 0 ], 1.0, 'expected result' ); - t.strictEqual( out[ 1 ], 2.0, 'expected result' ); - t.strictEqual( out[ 2 ], 0.0, 'expected result' ); - t.strictEqual( out[ 3 ], 0.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx; - var arr; - - function predicate( value ) { - return ( value !== value ); - } - - function sum( value ) { - /* eslint-disable no-invalid-this */ - this.sum += value; - this.count += 1; - } - - ctx = { - 'sum': 0, - 'count': 0 - }; - arr = [ 1.0, 2.0, 3.0 ]; - - untilEach( arr, predicate, sum, ctx ); - - t.strictEqual( ctx.sum/ctx.count, 2.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function provides basic support for dynamic arrays', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index, collection ) { - out.push( value ); - if ( index === collection.length-1 && collection.length < 10 ) { - collection.push( index+2 ); - } - } - - arr = [ 1, 2, 3 ]; - out = []; - - untilEach( arr, predicate, copy ); - - t.deepEqual( arr, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.deepEqual( out, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.end(); -}); - -tape( 'the function does not skip empty elements', function test( t ) { - var expected; - var arr; - - function predicate( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - return false; - } - - function verify( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - } - - arr = [ 1, , , 4 ]; // eslint-disable-line no-sparse-arrays - expected = [ 1, void 0, void 0, 4 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); - -tape( 'the function invokes the predicate function and the function to apply with three arguments: value, index, collection', function test( t ) { - var indices; - var values; - var arr; - - function predicate( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - return false; - } - - function verify( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - } - - arr = [ 1, 2, 3, 4 ]; - values = [ 1, 2, 3, 4 ]; - indices = [ 0, 1, 2, 3 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); From 4337fdbb70f6492707964663238c8e55feeed850 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Feb 2025 01:12:45 +0000 Subject: [PATCH 130/135] 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 846d968..42f57a7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,13 +56,13 @@ function untilEach( collection, predicate, fcn, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); + throw new TypeError( format( '1YDAh', collection ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '1YD2H', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '1YD3N', fcn ) ); } len = collection.length; i = 0; diff --git a/package.json b/package.json index 18396cb..5239c2e 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-collection": "^0.2.2", "@stdlib/assert-is-function": "^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 843f23b98b621879e73be2774af6301fee9b77f0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Feb 2025 01:36:21 +0000 Subject: [PATCH 131/135] Remove files --- index.d.ts | 142 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4989 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 355b4df..0000000 --- a/index.d.ts +++ /dev/null @@ -1,142 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Checks whether an element in a collection passes a test. -* -* @returns boolean indicating whether an element in a collection passes a test -*/ -type NullaryPredicate = () => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @returns boolean indicating whether an element in a collection passes a test -*/ -type UnaryPredicate = ( value: T ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @returns boolean indicating whether an element in a collection passes a test -*/ -type BinaryPredicate = ( value: T, index: number ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type TernaryPredicate = ( value: T, index: number, collection: Collection ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Predicate = NullaryPredicate | UnaryPredicate | BinaryPredicate | TernaryPredicate; - -/** -* Function invoked for each collection element until test condition is true. -*/ -type Nullary = ( this: U ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -*/ -type Unary = ( this: U, value: T ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -*/ -type Binary = ( this: U, value: T, index: number ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Ternary = ( this: U, value: T, index: number, collection: Collection ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Until a test condition is true, invokes a function once for each element in a collection. -* -* ## Notes -* -* - When invoked, both the predicate function and the function to apply are provided three arguments: -* -* - `value`: collection value -* - `index`: collection index -* - `collection`: the input collection -* -* @param collection - input collection -* @param predicate - function which indicates whether to stop iterating over a collection -* @param fcn - function to invoke -* @param thisArg - execution context for the applied function -* @returns input collection -* -* @example -* function predicate( v, key, collection ) { -* return ( v !== v ); -* } -* -* function log( v, key, collection ) { -* console.log( '%s: %d', key, v ); -* } -* -* var arr = [ 1, 2, 3, 4, NaN, 5 ]; -* -* untilEach( arr, predicate, log ); -*/ -declare function untilEach( collection: Collection, predicate: Predicate, fcn: Callback, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = untilEach; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 10553a0..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function s(s,o,i,n){var d,l;if(!r(s))throw new TypeError(e("1YDAh",s));if(!t(o))throw new TypeError(e("1YD2H",o));if(!t(i))throw new TypeError(e("1YD3N",i));for(d=s.length,l=0;l - - - - - - Rollup Visualizer - - - -
- - - - - From d9c1372a6fa5de9cb2c3c82d3008cb52024ab23c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 24 Feb 2025 01:36:37 +0000 Subject: [PATCH 132/135] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 219 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 89 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 47 - docs/types/test.ts | 89 - examples/index.js | 53 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 83 - package.json | 62 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 350 -- 44 files changed, 4868 insertions(+), 4460 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 44e93a6..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-02-24T01:05:44.952Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d70bfcd..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/utils/until-each) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 4eecda2..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/utils/until-each) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 aa2a9b4..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: '35 11 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -295,7 +286,7 @@ untilEach( arr, predicate, log ); ## 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]. @@ -366,9 +357,9 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right +[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right/tree/esm -[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each +[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each/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 754724d..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var untilEach = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var sum; - var i; - - function predicate( v ) { - return isnan( v ); - } - - function fcn( v ) { - sum += v; - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - untilEach( arr, predicate, fcn ); - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::loop', function benchmark( b ) { - var sum; - var arr; - var i; - var j; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - j = 0; - while ( j < arr.length ) { - if ( isnan( arr[ j ] ) ) { - break; - } - sum += arr[ j ]; - j += 1; - } - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 5ae3876..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/utils/until-each" -%% click B href "https://github.com/stdlib-js/utils-until-each/tree/main" -%% click C href "https://github.com/stdlib-js/utils-until-each/tree/production" -%% click D href "https://github.com/stdlib-js/utils-until-each/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-until-each/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-until-each/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/until-each -[production-url]: https://github.com/stdlib-js/utils-until-each/tree/production -[deno-url]: https://github.com/stdlib-js/utils-until-each/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-until-each/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-until-each/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-until-each/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-until-each/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-until-each/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 4378886..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import untilEach from '../docs/types/index'; -export = untilEach; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 52eaf73..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var g=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var m=g(function(E,s){ -var h=require('@stdlib/assert-is-collection/dist'),n=require('@stdlib/assert-is-function/dist'),i=require('@stdlib/error-tools-fmtprodmsg/dist');function w(r,e,a,v){var t,u;if(!h(r))throw new TypeError(i('1YDAh',r));if(!n(e))throw new TypeError(i('1YD2H',e));if(!n(a))throw new TypeError(i('1YD3N',a));for(t=r.length,u=0;u function predicate( v ) { return v !== v; }; - > function logger( v, i ) { console.log( '%s: %d', i, v ); }; - > var arr = [ 1, 2, 3, 4, NaN, 5 ]; - > {{alias}}( arr, predicate, logger ) - 0: 1 - 1: 2 - 2: 3 - 3: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4833283..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,89 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 untilEach = require( './index' ); - -/** -* Test function. -* -* @param v - value -* @param index - index -*/ -function fcn( v: number, index: number ): void { - if ( v !== v ) { - throw new Error( 'beep' ); - } - if ( index !== index ) { - throw new Error( 'beep' ); - } -} - -/** -* Test function. -* -* @param v - value -* @returns result -*/ -function isnan( v: number ): boolean { - return ( v !== v ); -} - - -// TESTS // - -// The function returns the input collection... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, fcn ); // $ExpectType Collection - untilEach( [ -1, 1, 2 ], isnan, fcn, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - untilEach( 2, isnan, fcn ); // $ExpectError - untilEach( false, isnan, fcn ); // $ExpectError - untilEach( true, isnan, fcn ); // $ExpectError - untilEach( {}, isnan, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], 2, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], false, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], true, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], 'abc', fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], {}, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], [], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, 2 ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, false ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, true ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, 'abc' ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, {} ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - untilEach(); // $ExpectError - untilEach( [ 1, 2, 3 ] ); // $ExpectError - untilEach( [ 1, 2, 3 ], isnan ); // $ExpectError - untilEach( [ 1, 2, 3 ], isnan, fcn, {}, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index c41d90c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isEven = require( '@stdlib/assert-is-even' ).isPrimitive; -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var untilEach = require( './../lib' ); - -function predicate( value ) { - return ( value !== value ); -} - -function log( value, index, collection ) { - console.log( '%s: %d', index, value ); - if ( isEven( index ) ) { - collection.shift(); - } else { - collection.push( index+1 ); - } -} - -var arr; -var j; -var i; - -arr = new Array( 100 ); -j = floor( randu()*arr.length ); -for ( i = 0; i < arr.length; i++ ) { - if ( i === j ) { - arr[ i ] = NaN; - } else { - arr[ i ] = i; - } -} - -untilEach( arr, predicate, log ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 19fe169..355b4df 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..c2223d4 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function s(s,o,i,n){var d,l;if(!r(s))throw new TypeError(e("1YDAh",s));if(!t(o))throw new TypeError(e("1YD2H",o));if(!t(i))throw new TypeError(e("1YD3N",i));for(d=s.length,l=0;l=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b4d9451 --- /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 70a1888..0000000 --- a/test/test.js +++ /dev/null @@ -1,350 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var untilEach = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof untilEach, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {}, - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( value, noop, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a predicate function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a function to invoke', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], noop, value ); - }; - } -}); - -tape( 'if provided an empty collection, the function never invokes a provided function', function test( t ) { - var arr = []; - - function predicate() { - t.fail( 'should not be invoked' ); - } - - function foo() { - t.fail( 'should not be invoked' ); - } - - untilEach( arr, predicate, foo ); - - t.deepEqual( arr, [], 'expected result' ); - t.end(); -}); - -tape( 'the function returns the input collection', function test( t ) { - var arr; - var out; - - function predicate() { - t.pass( 'invoked predicated function' ); - return false; - } - - function foo() { - t.pass( 'invoked provided function' ); - } - - arr = [ 1, 2, 3 ]; - - out = untilEach( arr, predicate, foo ); - - t.strictEqual( out, arr, 'returns input collection' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array)', function test( t ) { - var arr; - var out; - - arr = [ 1, 2, NaN, 3 ]; - out = [ 0, 0, 0, 0 ]; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - untilEach( arr, predicate, copy ); - - t.deepEqual( out, [ 1, 2, 0, 0 ], 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array-like object)', function test( t ) { - var expected; - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = { - 'length': 4, - '0': 1, - '1': 2, - '2': NaN, - '3': 3 - }; - out = { - 'length': 4, - '0': 0, - '1': 0, - '2': 0, - '3': 0 - }; - - untilEach( arr, predicate, copy ); - - expected = { - 'length': 4, - '0': 1, - '1': 2, - '2': 0, - '3': 0 - }; - - t.deepEqual( out, expected, 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (typed array)', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = new Float64Array( [ 1.0, 2.0, NaN, 3.0 ] ); - out = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - untilEach( arr, predicate, copy ); - - t.strictEqual( out[ 0 ], 1.0, 'expected result' ); - t.strictEqual( out[ 1 ], 2.0, 'expected result' ); - t.strictEqual( out[ 2 ], 0.0, 'expected result' ); - t.strictEqual( out[ 3 ], 0.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx; - var arr; - - function predicate( value ) { - return ( value !== value ); - } - - function sum( value ) { - /* eslint-disable no-invalid-this */ - this.sum += value; - this.count += 1; - } - - ctx = { - 'sum': 0, - 'count': 0 - }; - arr = [ 1.0, 2.0, 3.0 ]; - - untilEach( arr, predicate, sum, ctx ); - - t.strictEqual( ctx.sum/ctx.count, 2.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function provides basic support for dynamic arrays', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index, collection ) { - out.push( value ); - if ( index === collection.length-1 && collection.length < 10 ) { - collection.push( index+2 ); - } - } - - arr = [ 1, 2, 3 ]; - out = []; - - untilEach( arr, predicate, copy ); - - t.deepEqual( arr, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.deepEqual( out, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.end(); -}); - -tape( 'the function does not skip empty elements', function test( t ) { - var expected; - var arr; - - function predicate( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - return false; - } - - function verify( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - } - - arr = [ 1, , , 4 ]; // eslint-disable-line no-sparse-arrays - expected = [ 1, void 0, void 0, 4 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); - -tape( 'the function invokes the predicate function and the function to apply with three arguments: value, index, collection', function test( t ) { - var indices; - var values; - var arr; - - function predicate( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - return false; - } - - function verify( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - } - - arr = [ 1, 2, 3, 4 ]; - values = [ 1, 2, 3, 4 ]; - indices = [ 0, 1, 2, 3 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); From 1180c5cc9d1e48a89136eb63679361c955a7fdab Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 14 Apr 2025 01:18:01 +0000 Subject: [PATCH 133/135] 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 846d968..42f57a7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isCollection = require( '@stdlib/assert-is-collection' ); var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -56,13 +56,13 @@ function untilEach( collection, predicate, fcn, thisArg ) { var len; var i; if ( !isCollection( collection ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a collection. Value: `%s`.', collection ) ); + throw new TypeError( format( '1YDAh', collection ) ); } if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '1YD2H', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '1YD3N', fcn ) ); } len = collection.length; i = 0; diff --git a/package.json b/package.json index 18396cb..5239c2e 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-collection": "^0.2.2", "@stdlib/assert-is-function": "^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 b945790c9fad4a692bfcc43ed6f0d73148efb7d1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 14 Apr 2025 01:28:58 +0000 Subject: [PATCH 134/135] Remove files --- index.d.ts | 142 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4989 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 355b4df..0000000 --- a/index.d.ts +++ /dev/null @@ -1,142 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection } from '@stdlib/types/array'; - -/** -* Checks whether an element in a collection passes a test. -* -* @returns boolean indicating whether an element in a collection passes a test -*/ -type NullaryPredicate = () => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @returns boolean indicating whether an element in a collection passes a test -*/ -type UnaryPredicate = ( value: T ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @returns boolean indicating whether an element in a collection passes a test -*/ -type BinaryPredicate = ( value: T, index: number ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type TernaryPredicate = ( value: T, index: number, collection: Collection ) => boolean; - -/** -* Checks whether an element in a collection passes a test. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -* @returns boolean indicating whether an element in a collection passes a test -*/ -type Predicate = NullaryPredicate | UnaryPredicate | BinaryPredicate | TernaryPredicate; - -/** -* Function invoked for each collection element until test condition is true. -*/ -type Nullary = ( this: U ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -*/ -type Unary = ( this: U, value: T ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -*/ -type Binary = ( this: U, value: T, index: number ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Ternary = ( this: U, value: T, index: number, collection: Collection ) => void; - -/** -* Function invoked for each collection element until test condition is true. -* -* @param value - collection value -* @param index - collection index -* @param collection - input collection -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Until a test condition is true, invokes a function once for each element in a collection. -* -* ## Notes -* -* - When invoked, both the predicate function and the function to apply are provided three arguments: -* -* - `value`: collection value -* - `index`: collection index -* - `collection`: the input collection -* -* @param collection - input collection -* @param predicate - function which indicates whether to stop iterating over a collection -* @param fcn - function to invoke -* @param thisArg - execution context for the applied function -* @returns input collection -* -* @example -* function predicate( v, key, collection ) { -* return ( v !== v ); -* } -* -* function log( v, key, collection ) { -* console.log( '%s: %d', key, v ); -* } -* -* var arr = [ 1, 2, 3, 4, NaN, 5 ]; -* -* untilEach( arr, predicate, log ); -*/ -declare function untilEach( collection: Collection, predicate: Predicate, fcn: Callback, thisArg?: ThisParameterType> ): Collection; - - -// EXPORTS // - -export = untilEach; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index c2223d4..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function s(s,o,i,n){var d,l;if(!r(s))throw new TypeError(e("1YDAh",s));if(!t(o))throw new TypeError(e("1YD2H",o));if(!t(i))throw new TypeError(e("1YD3N",i));for(d=s.length,l=0;l - - - - - - Rollup Visualizer - - - -
- - - - - From 01ae752bc479a9bf5562409e2f3edb4ca9ff0a63 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 14 Apr 2025 01:29:18 +0000 Subject: [PATCH 135/135] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 219 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 89 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 47 - docs/types/test.ts | 89 - examples/index.js | 53 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 49 - lib/main.js | 83 - package.json | 62 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 350 -- 44 files changed, 4868 insertions(+), 4460 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 725fbbd..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-04-14T01:12:09.459Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index d70bfcd..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/utils/until-each) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 4eecda2..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/utils/until-each) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 aa2a9b4..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: '35 11 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -295,7 +286,7 @@ untilEach( arr, predicate, log ); ## 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]. @@ -366,9 +357,9 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right +[@stdlib/utils/until-each-right]: https://github.com/stdlib-js/utils-until-each-right/tree/esm -[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each +[@stdlib/utils/while-each]: https://github.com/stdlib-js/utils-while-each/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 754724d..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,89 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var untilEach = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var arr; - var sum; - var i; - - function predicate( v ) { - return isnan( v ); - } - - function fcn( v ) { - sum += v; - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - untilEach( arr, predicate, fcn ); - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::loop', function benchmark( b ) { - var sum; - var arr; - var i; - var j; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - arr = [ i, i+1, i+2, i+3, i+4 ]; - sum = 0; - j = 0; - while ( j < arr.length ) { - if ( isnan( arr[ j ] ) ) { - break; - } - sum += arr[ j ]; - j += 1; - } - if ( arr.length !== 5 ) { - b.fail( 'should not change the array length' ); - } - } - b.toc(); - if ( arr.length !== 5 || isnan( sum ) ) { - b.fail( 'should not change the array length' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 5ae3876..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/utils/until-each" -%% click B href "https://github.com/stdlib-js/utils-until-each/tree/main" -%% click C href "https://github.com/stdlib-js/utils-until-each/tree/production" -%% click D href "https://github.com/stdlib-js/utils-until-each/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-until-each/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-until-each/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/until-each -[production-url]: https://github.com/stdlib-js/utils-until-each/tree/production -[deno-url]: https://github.com/stdlib-js/utils-until-each/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-until-each/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-until-each/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-until-each/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-until-each/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-until-each/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 4378886..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import untilEach from '../docs/types/index'; -export = untilEach; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 52eaf73..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var g=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var m=g(function(E,s){ -var h=require('@stdlib/assert-is-collection/dist'),n=require('@stdlib/assert-is-function/dist'),i=require('@stdlib/error-tools-fmtprodmsg/dist');function w(r,e,a,v){var t,u;if(!h(r))throw new TypeError(i('1YDAh',r));if(!n(e))throw new TypeError(i('1YD2H',e));if(!n(a))throw new TypeError(i('1YD3N',a));for(t=r.length,u=0;u function predicate( v ) { return v !== v; }; - > function logger( v, i ) { console.log( '%s: %d', i, v ); }; - > var arr = [ 1, 2, 3, 4, NaN, 5 ]; - > {{alias}}( arr, predicate, logger ) - 0: 1 - 1: 2 - 2: 3 - 3: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4833283..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,89 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 untilEach = require( './index' ); - -/** -* Test function. -* -* @param v - value -* @param index - index -*/ -function fcn( v: number, index: number ): void { - if ( v !== v ) { - throw new Error( 'beep' ); - } - if ( index !== index ) { - throw new Error( 'beep' ); - } -} - -/** -* Test function. -* -* @param v - value -* @returns result -*/ -function isnan( v: number ): boolean { - return ( v !== v ); -} - - -// TESTS // - -// The function returns the input collection... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, fcn ); // $ExpectType Collection - untilEach( [ -1, 1, 2 ], isnan, fcn, {} ); // $ExpectType Collection -} - -// The compiler throws an error if the function is provided a first argument which is not a collection... -{ - untilEach( 2, isnan, fcn ); // $ExpectError - untilEach( false, isnan, fcn ); // $ExpectError - untilEach( true, isnan, fcn ); // $ExpectError - untilEach( {}, isnan, fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], 2, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], false, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], true, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], 'abc', fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], {}, fcn ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], [], fcn ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a function... -{ - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, 2 ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, false ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, true ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, 'abc' ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, {} ); // $ExpectError - untilEach( [ 0, 1, 1, NaN, 2 ], isnan, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - untilEach(); // $ExpectError - untilEach( [ 1, 2, 3 ] ); // $ExpectError - untilEach( [ 1, 2, 3 ], isnan ); // $ExpectError - untilEach( [ 1, 2, 3 ], isnan, fcn, {}, 3 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index c41d90c..0000000 --- a/examples/index.js +++ /dev/null @@ -1,53 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 isEven = require( '@stdlib/assert-is-even' ).isPrimitive; -var randu = require( '@stdlib/random-base-randu' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var untilEach = require( './../lib' ); - -function predicate( value ) { - return ( value !== value ); -} - -function log( value, index, collection ) { - console.log( '%s: %d', index, value ); - if ( isEven( index ) ) { - collection.shift(); - } else { - collection.push( index+1 ); - } -} - -var arr; -var j; -var i; - -arr = new Array( 100 ); -j = floor( randu()*arr.length ); -for ( i = 0; i < arr.length; i++ ) { - if ( i === j ) { - arr[ i ] = NaN; - } else { - arr[ i ] = i; - } -} - -untilEach( arr, predicate, log ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 19fe169..355b4df 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..c2223d4 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-collection@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function s(s,o,i,n){var d,l;if(!r(s))throw new TypeError(e("1YDAh",s));if(!t(o))throw new TypeError(e("1YD2H",o));if(!t(i))throw new TypeError(e("1YD3N",i));for(d=s.length,l=0;l=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b4d9451 --- /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 70a1888..0000000 --- a/test/test.js +++ /dev/null @@ -1,350 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 Float32Array = require( '@stdlib/array-float32' ); -var Float64Array = require( '@stdlib/array-float64' ); -var untilEach = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof untilEach, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a collection', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - function noop() {}, - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( value, noop, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a predicate function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a function to invoke', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - untilEach( [ 1, 2, 3 ], noop, value ); - }; - } -}); - -tape( 'if provided an empty collection, the function never invokes a provided function', function test( t ) { - var arr = []; - - function predicate() { - t.fail( 'should not be invoked' ); - } - - function foo() { - t.fail( 'should not be invoked' ); - } - - untilEach( arr, predicate, foo ); - - t.deepEqual( arr, [], 'expected result' ); - t.end(); -}); - -tape( 'the function returns the input collection', function test( t ) { - var arr; - var out; - - function predicate() { - t.pass( 'invoked predicated function' ); - return false; - } - - function foo() { - t.pass( 'invoked provided function' ); - } - - arr = [ 1, 2, 3 ]; - - out = untilEach( arr, predicate, foo ); - - t.strictEqual( out, arr, 'returns input collection' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array)', function test( t ) { - var arr; - var out; - - arr = [ 1, 2, NaN, 3 ]; - out = [ 0, 0, 0, 0 ]; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - untilEach( arr, predicate, copy ); - - t.deepEqual( out, [ 1, 2, 0, 0 ], 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (array-like object)', function test( t ) { - var expected; - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = { - 'length': 4, - '0': 1, - '1': 2, - '2': NaN, - '3': 3 - }; - out = { - 'length': 4, - '0': 0, - '1': 0, - '2': 0, - '3': 0 - }; - - untilEach( arr, predicate, copy ); - - expected = { - 'length': 4, - '0': 1, - '1': 2, - '2': 0, - '3': 0 - }; - - t.deepEqual( out, expected, 'expected result' ); - t.end(); -}); - -tape( 'until a test condition is true, the function invokes a provided function for each element in a collection (typed array)', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index ) { - out[ index ] = value; - } - - arr = new Float64Array( [ 1.0, 2.0, NaN, 3.0 ] ); - out = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); - - untilEach( arr, predicate, copy ); - - t.strictEqual( out[ 0 ], 1.0, 'expected result' ); - t.strictEqual( out[ 1 ], 2.0, 'expected result' ); - t.strictEqual( out[ 2 ], 0.0, 'expected result' ); - t.strictEqual( out[ 3 ], 0.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx; - var arr; - - function predicate( value ) { - return ( value !== value ); - } - - function sum( value ) { - /* eslint-disable no-invalid-this */ - this.sum += value; - this.count += 1; - } - - ctx = { - 'sum': 0, - 'count': 0 - }; - arr = [ 1.0, 2.0, 3.0 ]; - - untilEach( arr, predicate, sum, ctx ); - - t.strictEqual( ctx.sum/ctx.count, 2.0, 'expected result' ); - - t.end(); -}); - -tape( 'the function provides basic support for dynamic arrays', function test( t ) { - var arr; - var out; - - function predicate( value ) { - return ( value !== value ); - } - - function copy( value, index, collection ) { - out.push( value ); - if ( index === collection.length-1 && collection.length < 10 ) { - collection.push( index+2 ); - } - } - - arr = [ 1, 2, 3 ]; - out = []; - - untilEach( arr, predicate, copy ); - - t.deepEqual( arr, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.deepEqual( out, [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], 'expected result' ); - t.end(); -}); - -tape( 'the function does not skip empty elements', function test( t ) { - var expected; - var arr; - - function predicate( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - return false; - } - - function verify( value, index ) { - t.strictEqual( value, expected[ index ], 'provides expected value' ); - } - - arr = [ 1, , , 4 ]; // eslint-disable-line no-sparse-arrays - expected = [ 1, void 0, void 0, 4 ]; - - untilEach( arr, predicate, verify ); - t.end(); -}); - -tape( 'the function invokes the predicate function and the function to apply with three arguments: value, index, collection', function test( t ) { - var indices; - var values; - var arr; - - function predicate( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - return false; - } - - function verify( value, index, collection ) { - t.strictEqual( value, values[ index ], 'provides expected value' ); - t.strictEqual( index, indices[ index ], 'provides expected index' ); - t.strictEqual( collection, arr, 'provides input collection' ); - } - - arr = [ 1, 2, 3, 4 ]; - values = [ 1, 2, 3, 4 ]; - indices = [ 0, 1, 2, 3 ]; - - untilEach( arr, predicate, verify ); - t.end(); -});