From 25f9f37292117473ffa432d522ba25e65cc020a0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Apr 2022 04:06:11 +0000 Subject: [PATCH 001/143] Auto-generated commit 4f9f953bf4e736c2d377178672402aad168b1ea9 --- CONTRIBUTORS | 28 + LICENSE | 481 +++++++++ NOTICE | 1 + README.md | 348 +++++++ index.d.ts | 127 +++ index.mjs | 4 + index.mjs.map | 1 + package.json | 36 + stats.html | 2689 +++++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 3715 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..608b9be --- /dev/null +++ b/README.md @@ -0,0 +1,348 @@ + + +# whileAsync + +[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] + +> Invoke a function while a test condition is true. + + + +
+ +
+ + + + + + + +
+ +## Usage + +```javascript +import whileAsync from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-async-while@esm/index.mjs'; +``` + +#### whileAsync( predicate, fcn, done\[, thisArg ] ) + +Invokes a `function` until a `predicate` function returns `false`. + +```javascript +function predicate( i, clbk ) { + clbk( null, i < 5 ); +} + +function fcn( i, next ) { + setTimeout( onTimeout, 0 ); + function onTimeout() { + console.log( 'beep: %d', i ); + next(); + } +} + +function done( error ) { + if ( error ) { + throw error; + } +} + +whileAsync( predicate, fcn, done ); +/* => + beep: 0 + beep: 1 + beep: 2 + beep: 3 + beep: 4 +*/ +``` + +The `predicate` function is provided two arguments: + +- `i`: iteration number (starting from zero) +- `clbk`: a callback indicating whether to invoke `fcn` + +The `clbk` function accepts two arguments: + +- `error`: error object +- `bool`: test result + +If the test result is truthy, the function invokes `fcn`; otherwise, the function invokes the `done` callback. + +The function to invoke is provided two arguments: + +- `i`: iteration number (starting from zero) +- `next`: a callback which must be invoked before proceeding to the next iteration + +The first argument of both `clbk` and `next` is an `error` argument. If either function is called with a truthy `error` argument, the function suspends execution and immediately calls the `done` callback for subsequent `error` handling. + +```javascript +function predicate( i, clbk ) { + clbk( null, i < 5 ); +} + +function fcn( i, next ) { + setTimeout( onTimeout, 0 ); + function onTimeout() { + next( new Error( 'beep' ) ); + } +} + +function done( error ) { + console.error( error.message ); + // => beep +} + +whileAsync( predicate, fcn, done ); +``` + +The `done` callback is invoked with an `error` argument and any arguments passed to the final `next` callback. + +```javascript +function predicate( i, clbk ) { + clbk( null, i < 5 ); +} + +function fcn( i, next ) { + setTimeout( onTimeout, 0 ); + function onTimeout() { + next( null, i ); + } +} + +function done( error, result ) { + if ( error ) { + throw error; + } + console.log( result ); + // => 4 +} + +whileAsync( predicate, fcn, done ); +``` + +To set the function execution context for the invoked function, provide a `thisArg`. + + + +```javascript +function predicate( i, clbk ) { + clbk( null, i < 5 ); +} + +function fcn( i, next ) { + this.count += 1; + setTimeout( onTimeout, 0 ); + function onTimeout() { + next(); + } +} + +var context = { + 'count': 0 +}; + +whileAsync( predicate, fcn, done, context ); + +function done( error ) { + if ( error ) { + throw error; + } + console.log( context.count ); + // => 5 +} +``` + +
+ + + + + +
+ +## Notes + +- Execution is **not** guaranteed to be asynchronous. To guarantee asynchrony, wrap the `done` callback in a function which either executes at the end of the current stack (e.g., `nextTick`) or during a subsequent turn of the event loop (e.g., `setImmediate`, `setTimeout`). + +
+ + + + + +
+ +## 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..b390f4c --- /dev/null +++ b/index.d.ts @@ -0,0 +1,127 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2021 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT 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 + +/** +* Callback function. +*/ +type Nullary = () => void; + +/** +* Callback function. +* +* @param error - encountered error or null +*/ +type Unary = ( error: Error | null ) => void; + +/** +* Callback function. +* +* @param error - encountered error or null +* @param bool - test result +*/ +type Binary = ( error: Error | null, bool: boolean ) => void; + +/** +* Callback function. +* +* @param error - encountered error or null +* @param bool - test result +*/ +type Callback = Nullary | Unary | Binary; + +/** +* Callback invoked upon completion. +*/ +type DoneNullary = () => void; + +/** +* Callback invoked upon completion. +* +* @param error - encountered error or null +*/ +type DoneUnary = ( error: Error | null ) => void; + +/** +* Callback invoked upon completion. +* +* @param error - encountered error or null +* @param args - arguments passed to last `next` call +*/ +type DoneBinary = ( error: Error | null, ...args: Array ) => void; + +/** +* Callback invoked upon completion. +* +* @param error - encountered error or null +* @param args - arguments passed to last `next` call +*/ +type DoneCallback = DoneNullary | DoneUnary | DoneBinary; + +/** +* Checks whether an element in a collection passes a test. +* +* @param i - iteration number (starting from one) +* @param clbk - a callback indicating whether to invoke `fcn` +*/ +type Predicate = ( i: number, clbk: Callback ) => void; + +/** +* Invoked function. +* +* @param i - iteration number (starting from zero) +* @param next - a callback which must be invoked before proceeding to the next iteration +*/ +type Fcn = ( i: number, next: Function ) => void; + +/** +* Invokes a function while a test condition is true. +* +* @param predicate - function which indicates whether to continue invoking a function +* @param fcn - function to invoke +* @param done - callback to invoke upon completion +* @param thisArg - execution context for the invoked function +* +* @example +* function predicate( i, clbk ) { +* clbk( null, i < 5 ); +* } +* +* function fcn( i, next ) { +* setTimeout( onTimeout, i ); +* function onTimeout() { +* console.log( 'beep: %d', i ); +* next(); +* } +* } +* +* function done( error ) { +* if ( error ) { +* throw error; +* } +* } +* +* whileAsync( predicate, fcn, done ); +*/ +declare function whileAsync( predicate: Predicate, fcn: Fcn, done: DoneCallback, thisArg?: any ): void; // tslint-disable-line max-line-length + + +// EXPORTS // + +export = whileAsync; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..8728882 --- /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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@esm/index.mjs";var r=n,e=t;var i=function(n,t,i,a){var s,u;if(!r(n))throw new TypeError(e("invalid argument. First argument must be a function. Value: `%s`.",n));if(!r(t))throw new TypeError(e("invalid argument. Second argument must be a function. Value: `%s`.",t));if(!r(i))throw new TypeError(e("invalid argument. Third argument must be a function. Value: `%s`.",i));function l(n,r){return n?i(n):r?t.call(a,u,o):(s.length&&s.unshift(null),void i.apply(null,s))}function o(t){var r;if(t)return i(t);if(u+=1,arguments.length>1)for(s=new Array(arguments.length-1),r=1;r 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = whileAsync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Invoke a function while a test condition is true.\n*\n* @module @stdlib/utils-async-while\n*\n* @example\n* var whileAsync = require( '@stdlib/utils-async-while' );\n*\n* function predicate( i, clbk ) {\n* clbk( null, i < 5 );\n* }\n*\n* function fcn( i, next ) {\n* setTimeout( onTimeout, i );\n* function onTimeout() {\n* console.log( 'beep: %d', i );\n* next();\n* }\n* }\n*\n* function done( error ) {\n* if ( error ) {\n* throw error;\n* }\n* }\n*\n* whileAsync( predicate, fcn, done );\n*/\n\n// MODULES //\n\nvar whileAsync = require( './while_async.js' );\n\n\n// EXPORTS //\n\nmodule.exports = whileAsync;\n"],"names":["isFunction","require$$0","format","require$$1","lib","predicate","fcn","done","thisArg","args","idx","TypeError","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;uKAsBA,IAAIA,EAAaC,EACbC,EAASC,EAwGb,ICvEAC,EDIA,SAAqBC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMV,EAAYK,GACjB,MAAM,IAAIM,UAAWT,EAAQ,oEAAqEG,IAEnG,IAAML,EAAYM,GACjB,MAAM,IAAIK,UAAWT,EAAQ,qEAAsEI,IAEpG,IAAMN,EAAYO,GACjB,MAAM,IAAII,UAAWT,EAAQ,oEAAqEK,IAcnG,SAASK,EAAaC,EAAOC,GAC5B,OAAKD,EACGN,EAAMM,GAETC,EACGR,EAAIS,KAAMP,EAASE,EAAKM,IAE3BP,EAAKQ,QACTR,EAAKS,QAAS,WAEfX,EAAKY,MAAO,KAAMV,IAWnB,SAASO,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAON,EAAMM,GAKd,GAHAH,GAAO,EAGFW,UAAUJ,OAAS,EAEvB,IADAR,EAAO,IAAIa,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCX,EAAMW,EAAE,GAAMC,UAAWD,GAI3Bf,EAAWK,EAAKE,GAhDjBH,EAAO,GAEPJ,EADAK,EAAM,EACUE"} \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..2382300 --- /dev/null +++ b/package.json @@ -0,0 +1,36 @@ +{ + "name": "@stdlib/utils-async-while", + "version": "0.0.0", + "description": "Invoke a function while a test condition is true.", + "license": "Apache-2.0", + "type": "module", + "main": "./index.mjs", + "homepage": "https://stdlib.io", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/utils-async-while.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "keywords": [ + "stdlib", + "stdutils", + "stdutil", + "utilities", + "utility", + "utils", + "util", + "asynchronous", + "async", + "for", + "while", + "loop", + "iterate", + "iteration" + ], + "funding": { + "type": "patreon", + "url": "https://www.patreon.com/athan" + } +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..321bc13 --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + From b1bb76f4a7e05ff73d0b394365e44b521bdc6d5b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 30 Jun 2022 23:07:44 +0000 Subject: [PATCH 002/143] Transform error messages --- lib/while_async.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/while_async.js b/lib/while_async.js index 1dafc2a..c03bb93 100644 --- a/lib/while_async.js +++ b/lib/while_async.js @@ -21,7 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -62,13 +62,13 @@ function whileAsync( predicate, fcn, done, thisArg ) { var args; var idx; if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '0im3p', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0im2S', fcn ) ); } if ( !isFunction( done ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', done ) ); + throw new TypeError( format( '0im3Z', done ) ); } args = []; idx = 0; diff --git a/package.json b/package.json index db2fdb6..fcdbeed 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ }, "dependencies": { "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/string-format": "^0.0.x" + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/bench": "^0.0.x", From 669027bd1ec4cbd3f68bedbf1be15e59b38784ab Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 10:30:19 +0000 Subject: [PATCH 003/143] Remove files --- index.d.ts | 127 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2821 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 b390f4c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,127 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Callback function. -*/ -type Nullary = () => void; - -/** -* Callback function. -* -* @param error - encountered error or null -*/ -type Unary = ( error: Error | null ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Binary = ( error: Error | null, bool: boolean ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Callback = Nullary | Unary | Binary; - -/** -* Callback invoked upon completion. -*/ -type DoneNullary = () => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -*/ -type DoneUnary = ( error: Error | null ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneBinary = ( error: Error | null, ...args: Array ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneCallback = DoneNullary | DoneUnary | DoneBinary; - -/** -* Checks whether an element in a collection passes a test. -* -* @param i - iteration number (starting from one) -* @param clbk - a callback indicating whether to invoke `fcn` -*/ -type Predicate = ( i: number, clbk: Callback ) => void; - -/** -* Invoked function. -* -* @param i - iteration number (starting from zero) -* @param next - a callback which must be invoked before proceeding to the next iteration -*/ -type Fcn = ( i: number, next: Function ) => void; - -/** -* Invokes a function while a test condition is true. -* -* @param predicate - function which indicates whether to continue invoking a function -* @param fcn - function to invoke -* @param done - callback to invoke upon completion -* @param thisArg - execution context for the invoked function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -declare function whileAsync( predicate: Predicate, fcn: Fcn, done: DoneCallback, thisArg?: any ): void; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = whileAsync; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 8728882..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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@esm/index.mjs";var r=n,e=t;var i=function(n,t,i,a){var s,u;if(!r(n))throw new TypeError(e("invalid argument. First argument must be a function. Value: `%s`.",n));if(!r(t))throw new TypeError(e("invalid argument. Second argument must be a function. Value: `%s`.",t));if(!r(i))throw new TypeError(e("invalid argument. Third argument must be a function. Value: `%s`.",i));function l(n,r){return n?i(n):r?t.call(a,u,o):(s.length&&s.unshift(null),void i.apply(null,s))}function o(t){var r;if(t)return i(t);if(u+=1,arguments.length>1)for(s=new Array(arguments.length-1),r=1;r 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = whileAsync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Invoke a function while a test condition is true.\n*\n* @module @stdlib/utils-async-while\n*\n* @example\n* var whileAsync = require( '@stdlib/utils-async-while' );\n*\n* function predicate( i, clbk ) {\n* clbk( null, i < 5 );\n* }\n*\n* function fcn( i, next ) {\n* setTimeout( onTimeout, i );\n* function onTimeout() {\n* console.log( 'beep: %d', i );\n* next();\n* }\n* }\n*\n* function done( error ) {\n* if ( error ) {\n* throw error;\n* }\n* }\n*\n* whileAsync( predicate, fcn, done );\n*/\n\n// MODULES //\n\nvar whileAsync = require( './while_async.js' );\n\n\n// EXPORTS //\n\nmodule.exports = whileAsync;\n"],"names":["isFunction","require$$0","format","require$$1","lib","predicate","fcn","done","thisArg","args","idx","TypeError","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;uKAsBA,IAAIA,EAAaC,EACbC,EAASC,EAwGb,ICvEAC,EDIA,SAAqBC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMV,EAAYK,GACjB,MAAM,IAAIM,UAAWT,EAAQ,oEAAqEG,IAEnG,IAAML,EAAYM,GACjB,MAAM,IAAIK,UAAWT,EAAQ,qEAAsEI,IAEpG,IAAMN,EAAYO,GACjB,MAAM,IAAII,UAAWT,EAAQ,oEAAqEK,IAcnG,SAASK,EAAaC,EAAOC,GAC5B,OAAKD,EACGN,EAAMM,GAETC,EACGR,EAAIS,KAAMP,EAASE,EAAKM,IAE3BP,EAAKQ,QACTR,EAAKS,QAAS,WAEfX,EAAKY,MAAO,KAAMV,IAWnB,SAASO,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAON,EAAMM,GAKd,GAHAH,GAAO,EAGFW,UAAUJ,OAAS,EAEvB,IADAR,EAAO,IAAIa,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCX,EAAMW,EAAE,GAAMC,UAAWD,GAI3Bf,EAAWK,EAAKE,GAhDjBH,EAAO,GAEPJ,EADAK,EAAM,EACUE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 321bc13..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 6cec706831d92264c78e8f11304ed216c16bc080 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 10:31:05 +0000 Subject: [PATCH 004/143] 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 | 105 - branches.md | 53 - docs/repl.txt | 72 - docs/types/test.ts | 83 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 57 - lib/while_async.js | 128 - package.json | 56 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 328 --- 37 files changed, 2714 insertions(+), 3799 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 (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/while_async.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 8327d7e..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-06-30T21:20:01.185Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 0f8dec8..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/async/while) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 d8c823e..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/async/while) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -279,7 +272,7 @@ whileAsync( predicate, fcn, done ); ## 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]. @@ -341,13 +334,13 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until +[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until/tree/esm -[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while +[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while/tree/esm -[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until +[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until/tree/esm -[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while +[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index ae9d749..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var whileAsync = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); - -bench( pkg+'::sync_predicate', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 576a70c..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/async/while" -click B href "https://github.com/stdlib-js/utils-async-while/tree/main" -click C href "https://github.com/stdlib-js/utils-async-while/tree/production" -click D href "https://github.com/stdlib-js/utils-async-while/tree/esm" -click E href "https://github.com/stdlib-js/utils-async-while/tree/deno" -click F href "https://github.com/stdlib-js/utils-async-while/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/async/while -[production-url]: https://github.com/stdlib-js/utils-async-while/tree/production -[deno-url]: https://github.com/stdlib-js/utils-async-while/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-async-while/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-async-while/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index d7ca8c9..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,72 +0,0 @@ - -{{alias}}( predicate, fcn, done[, thisArg] ) - Invokes a function while a test condition is true. - - The predicate function is provided two arguments: - - - `i`: iteration number (starting from zero) - - `clbk`: a callback indicating whether to invoke `fcn` - - The `clbk` function accepts two arguments: - - - `error`: error argument - - `bool`: test result - - If the test result is truthy, the function invokes `fcn`; otherwise, the - function invokes the `done` callback. - - The function to invoke is provided two arguments: - - - `i`: iteration number (starting from zero) - - `next`: a callback which must be invoked before proceeding to the next - iteration - - The first argument of the `next` callback is an `error` argument. If `fcn` - calls the `next` callback with a truthy `error` argument, the function - suspends execution and immediately calls the `done` callback for subsequent - `error` handling. - - The `done` callback is invoked with an `error` argument and any arguments - passed to the final `next` callback. - - Execution is *not* guaranteed to be asynchronous. To guarantee asynchrony, - wrap the `done` callback in a function which either executes at the end of - the current stack (e.g., `nextTick`) or during a subsequent turn of the - event loop (e.g., `setImmediate`, `setTimeout`). - - Parameters - ---------- - predicate: Function - The predicate function which indicates whether to continue invoking a - function. - - fcn: Function - The function to invoke. - - done: Function - Callback to invoke upon completion. - - thisArg: any (optional) - Execution context for the invoked function. - - Examples - -------- - > function predicate( i, clbk ) { clbk( null, i < 5 ); }; - > function fcn( i, next ) { - ... setTimeout( onTimeout, i ); - ... function onTimeout() { - ... next( null, 'boop'+i ); - ... } - ... }; - > function done( error, result ) { - ... if ( error ) { - ... throw error; - ... } - ... console.log( result ); - ... }; - > {{alias}}( predicate, fcn, done ) - boop: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4a543d9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,83 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 whileAsync = require( './index' ); - -const fcn = ( i: number, next: Function ): void => { - if ( i === void 0 ) { - throw new Error( '`i` is missing.' ); - } - next(); -}; - -const predicate = ( i: number, clbk: Function ): void => { - clbk( null, i < 5 ); -}; - -const done = ( error: Error | null ): void => { - if ( error ) { - throw error; - } -}; - - -// TESTS // - -// The function returns void... -{ - whileAsync( predicate, fcn, done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a predicate function... -{ - whileAsync( 2, fcn, done ); // $ExpectError - whileAsync( false, fcn, done ); // $ExpectError - whileAsync( true, fcn, done ); // $ExpectError - whileAsync( 'abc', fcn, done ); // $ExpectError - whileAsync( {}, fcn, done ); // $ExpectError - whileAsync( [], fcn, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function having a supported signature... -{ - whileAsync( predicate, 2, done ); // $ExpectError - whileAsync( predicate, false, done ); // $ExpectError - whileAsync( predicate, true, done ); // $ExpectError - whileAsync( predicate, 'abc', done ); // $ExpectError - whileAsync( predicate, {}, done ); // $ExpectError - whileAsync( predicate, [], done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a done callback argument which is not a function having a supported signature... -{ - whileAsync( predicate, fcn, 2 ); // $ExpectError - whileAsync( predicate, fcn, false ); // $ExpectError - whileAsync( predicate, fcn, true ); // $ExpectError - whileAsync( predicate, fcn, 'abc' ); // $ExpectError - whileAsync( predicate, fcn, {} ); // $ExpectError - whileAsync( predicate, fcn, [] ); // $ExpectError - whileAsync( predicate, fcn, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - whileAsync(); // $ExpectError - whileAsync( predicate ); // $ExpectError - whileAsync( predicate, fcn ); // $ExpectError - whileAsync( predicate, fcn, done, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a6af668..0000000 --- a/examples/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var repeatString = require( '@stdlib/string-repeat' ); -var whileAsync = require( './../lib' ); - -function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } -} - -function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, repeatString( 'beep', i+1 ) ); - } -} - -function done( error, result ) { - if ( error ) { - throw error; - } - console.log( result ); -} - -whileAsync( predicate, fcn, done ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..19136e1 --- /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-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";function n(n,e,i,o){var s,l;if(!r(n))throw new TypeError(t("0im3p",n));if(!r(e))throw new TypeError(t("0im2S",e));if(!r(i))throw new TypeError(t("0im3Z",i));function f(r,t){return r?i(r):t?e.call(o,l,m):(s.length&&s.unshift(null),void i.apply(null,s))}function m(r){var t;if(r)return i(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;gLA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,IAWnB,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,GAhDjBL,EAAO,GAEPJ,EADAK,EAAM,EACUI"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index f0719b2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Invoke a function while a test condition is true. -* -* @module @stdlib/utils-async-while -* -* @example -* var whileAsync = require( '@stdlib/utils-async-while' ); -* -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ - -// MODULES // - -var whileAsync = require( './while_async.js' ); - - -// EXPORTS // - -module.exports = whileAsync; diff --git a/lib/while_async.js b/lib/while_async.js deleted file mode 100644 index c03bb93..0000000 --- a/lib/while_async.js +++ /dev/null @@ -1,128 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Invokes a function while a test condition is true. -* -* @param {Function} predicate - function which indicates whether to continue invoking a function -* @param {Function} fcn - function to invoke -* @param {Callback} done - callback to invoke upon completion -* @param {*} [thisArg] - execution context for the invoked function -* @throws {TypeError} first argument must be a function -* @throws {TypeError} second argument must be a function -* @throws {TypeError} third argument must be a function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -function whileAsync( predicate, fcn, done, thisArg ) { - var args; - var idx; - if ( !isFunction( predicate ) ) { - throw new TypeError( format( '0im3p', predicate ) ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0im2S', fcn ) ); - } - if ( !isFunction( done ) ) { - throw new TypeError( format( '0im3Z', done ) ); - } - args = []; - idx = 0; - predicate( idx, onPredicate ); - - /** - * Callback invoked upon a predicate result. - * - * @private - * @param {(Error|null)} error - error object - * @param {boolean} result - predicate result - * @returns {void} - */ - function onPredicate( error, result ) { - if ( error ) { - return done( error ); - } - if ( result ) { - return fcn.call( thisArg, idx, next ); - } - if ( args.length ) { - args.unshift( null ); // error argument - } - done.apply( null, args ); - } - - /** - * Callback invoked upon completion of a provided function. - * - * @private - * @param {(Error|null)} error - error object - * @param {...*} results - function results - * @returns {void} - */ - function next( error ) { - var i; - if ( error ) { - return done( error ); - } - idx += 1; - - // Cache the most recent results... - if ( arguments.length > 1 ) { - args = new Array( arguments.length-1 ); - for ( i = 1; i < arguments.length; i++ ) { - args[ i-1 ] = arguments[ i ]; - } - } - // Run the test condition: - predicate( idx, onPredicate ); - } -} - - -// EXPORTS // - -module.exports = whileAsync; diff --git a/package.json b/package.json index fcdbeed..411f4ec 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Invoke a function while a test condition is true.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,35 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/bench": "^0.0.x", - "@stdlib/math-base-assert-is-nan": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "@stdlib/string-repeat": "^0.0.x", - "@stdlib/utils-noop": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..9120385 --- /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 78d0688..0000000 --- a/test/test.js +++ /dev/null @@ -1,328 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 whileAsync = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof whileAsync, 'function', 'main export is a function' ); - t.end(); -}); - -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() { - whileAsync( value, noop, 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() { - whileAsync( noop, value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a callback 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() { - whileAsync( noop, noop, value ); - }; - } -}); - -tape( 'while a test condition is true, the function invokes a provided function', function test( t ) { - var indices1 = [ 0, 1, 2, 3, 4, 5 ]; - var indices2 = [ 0, 1, 2, 3, 4 ]; - var j = -1; - var k = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices1[ j ], 'provides expected value' ); - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - k += 1; - t.strictEqual( i, indices2[ k ], 'provides expected value' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'while a test condition is true, the function invokes a provided function (always false)', function test( t ) { - var indices = [ 0 ]; - var j = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices[ j ], 'provides expected value' ); - clbk( null, false ); - } - - function fcn( i, next ) { - t.fail( 'should never be invoked' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx = { - 'count': 0 - }; - - whileAsync( predicate, fcn, done, ctx ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - this.count += 1; // eslint-disable-line no-invalid-this - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( ctx.count, 5, 'updates context' ); - t.end(); - } -}); - -tape( 'the function provides any results to a `done` callback', function test( t ) { - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, 'beep'+i, 'boop'+i, 'woot'+i ); - } - } - - function done( error, str1, str2, str3 ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( str1, 'beep4', 'returns expected value' ); - t.strictEqual( str2, 'boop4', 'returns expected value' ); - t.strictEqual( str3, 'woot4', 'returns expected value' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the predicate function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - if ( i === 1 ) { - return clbk( new Error( 'beep' ) ); - } - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 2, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the provided function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - if ( i === 2 ) { - return next( new Error( 'boop' ) ); - } - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 3, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'the function does not guarantee asynchronous execution', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - k = 1; - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - next(); - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( k, 0, 'releases the zalgo' ); - t.end(); - } -}); From 0992d8450fda43b5ad60a182099c2bf56b6c5e73 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 16:41:53 +0000 Subject: [PATCH 005/143] Transform error messages --- lib/while_async.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/while_async.js b/lib/while_async.js index 1dafc2a..c03bb93 100644 --- a/lib/while_async.js +++ b/lib/while_async.js @@ -21,7 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -62,13 +62,13 @@ function whileAsync( predicate, fcn, done, thisArg ) { var args; var idx; if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '0im3p', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0im2S', fcn ) ); } if ( !isFunction( done ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', done ) ); + throw new TypeError( format( '0im3Z', done ) ); } args = []; idx = 0; diff --git a/package.json b/package.json index db2fdb6..fcdbeed 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ }, "dependencies": { "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/string-format": "^0.0.x" + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/bench": "^0.0.x", From f9178c32c22c9fb0794c6599381456dbae29b32d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Jul 2022 09:15:37 +0000 Subject: [PATCH 006/143] Remove files --- index.d.ts | 127 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2821 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 b390f4c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,127 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Callback function. -*/ -type Nullary = () => void; - -/** -* Callback function. -* -* @param error - encountered error or null -*/ -type Unary = ( error: Error | null ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Binary = ( error: Error | null, bool: boolean ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Callback = Nullary | Unary | Binary; - -/** -* Callback invoked upon completion. -*/ -type DoneNullary = () => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -*/ -type DoneUnary = ( error: Error | null ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneBinary = ( error: Error | null, ...args: Array ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneCallback = DoneNullary | DoneUnary | DoneBinary; - -/** -* Checks whether an element in a collection passes a test. -* -* @param i - iteration number (starting from one) -* @param clbk - a callback indicating whether to invoke `fcn` -*/ -type Predicate = ( i: number, clbk: Callback ) => void; - -/** -* Invoked function. -* -* @param i - iteration number (starting from zero) -* @param next - a callback which must be invoked before proceeding to the next iteration -*/ -type Fcn = ( i: number, next: Function ) => void; - -/** -* Invokes a function while a test condition is true. -* -* @param predicate - function which indicates whether to continue invoking a function -* @param fcn - function to invoke -* @param done - callback to invoke upon completion -* @param thisArg - execution context for the invoked function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -declare function whileAsync( predicate: Predicate, fcn: Fcn, done: DoneCallback, thisArg?: any ): void; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = whileAsync; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 19136e1..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-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";function n(n,e,i,o){var s,l;if(!r(n))throw new TypeError(t("0im3p",n));if(!r(e))throw new TypeError(t("0im2S",e));if(!r(i))throw new TypeError(t("0im3Z",i));function f(r,t){return r?i(r):t?e.call(o,l,m):(s.length&&s.unshift(null),void i.apply(null,s))}function m(r){var t;if(r)return i(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;gLA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,IAWnB,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,GAhDjBL,EAAO,GAEPJ,EADAK,EAAM,EACUI"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 9120385..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 6d449f1daf85719a5e31b127732fd98b75b4cec6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Jul 2022 09:16:14 +0000 Subject: [PATCH 007/143] 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 | 105 - branches.md | 53 - docs/repl.txt | 72 - docs/types/test.ts | 83 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 57 - lib/while_async.js | 128 - package.json | 56 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 328 --- 37 files changed, 2714 insertions(+), 3799 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 (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/while_async.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 f20bd1c..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-07-01T00:42:39.125Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 0f8dec8..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/async/while) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 d8c823e..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/async/while) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -279,7 +272,7 @@ whileAsync( predicate, fcn, done ); ## 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]. @@ -341,13 +334,13 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until +[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until/tree/esm -[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while +[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while/tree/esm -[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until +[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until/tree/esm -[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while +[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index ae9d749..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var whileAsync = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); - -bench( pkg+'::sync_predicate', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 576a70c..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/async/while" -click B href "https://github.com/stdlib-js/utils-async-while/tree/main" -click C href "https://github.com/stdlib-js/utils-async-while/tree/production" -click D href "https://github.com/stdlib-js/utils-async-while/tree/esm" -click E href "https://github.com/stdlib-js/utils-async-while/tree/deno" -click F href "https://github.com/stdlib-js/utils-async-while/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/async/while -[production-url]: https://github.com/stdlib-js/utils-async-while/tree/production -[deno-url]: https://github.com/stdlib-js/utils-async-while/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-async-while/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-async-while/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index d7ca8c9..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,72 +0,0 @@ - -{{alias}}( predicate, fcn, done[, thisArg] ) - Invokes a function while a test condition is true. - - The predicate function is provided two arguments: - - - `i`: iteration number (starting from zero) - - `clbk`: a callback indicating whether to invoke `fcn` - - The `clbk` function accepts two arguments: - - - `error`: error argument - - `bool`: test result - - If the test result is truthy, the function invokes `fcn`; otherwise, the - function invokes the `done` callback. - - The function to invoke is provided two arguments: - - - `i`: iteration number (starting from zero) - - `next`: a callback which must be invoked before proceeding to the next - iteration - - The first argument of the `next` callback is an `error` argument. If `fcn` - calls the `next` callback with a truthy `error` argument, the function - suspends execution and immediately calls the `done` callback for subsequent - `error` handling. - - The `done` callback is invoked with an `error` argument and any arguments - passed to the final `next` callback. - - Execution is *not* guaranteed to be asynchronous. To guarantee asynchrony, - wrap the `done` callback in a function which either executes at the end of - the current stack (e.g., `nextTick`) or during a subsequent turn of the - event loop (e.g., `setImmediate`, `setTimeout`). - - Parameters - ---------- - predicate: Function - The predicate function which indicates whether to continue invoking a - function. - - fcn: Function - The function to invoke. - - done: Function - Callback to invoke upon completion. - - thisArg: any (optional) - Execution context for the invoked function. - - Examples - -------- - > function predicate( i, clbk ) { clbk( null, i < 5 ); }; - > function fcn( i, next ) { - ... setTimeout( onTimeout, i ); - ... function onTimeout() { - ... next( null, 'boop'+i ); - ... } - ... }; - > function done( error, result ) { - ... if ( error ) { - ... throw error; - ... } - ... console.log( result ); - ... }; - > {{alias}}( predicate, fcn, done ) - boop: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4a543d9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,83 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 whileAsync = require( './index' ); - -const fcn = ( i: number, next: Function ): void => { - if ( i === void 0 ) { - throw new Error( '`i` is missing.' ); - } - next(); -}; - -const predicate = ( i: number, clbk: Function ): void => { - clbk( null, i < 5 ); -}; - -const done = ( error: Error | null ): void => { - if ( error ) { - throw error; - } -}; - - -// TESTS // - -// The function returns void... -{ - whileAsync( predicate, fcn, done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a predicate function... -{ - whileAsync( 2, fcn, done ); // $ExpectError - whileAsync( false, fcn, done ); // $ExpectError - whileAsync( true, fcn, done ); // $ExpectError - whileAsync( 'abc', fcn, done ); // $ExpectError - whileAsync( {}, fcn, done ); // $ExpectError - whileAsync( [], fcn, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function having a supported signature... -{ - whileAsync( predicate, 2, done ); // $ExpectError - whileAsync( predicate, false, done ); // $ExpectError - whileAsync( predicate, true, done ); // $ExpectError - whileAsync( predicate, 'abc', done ); // $ExpectError - whileAsync( predicate, {}, done ); // $ExpectError - whileAsync( predicate, [], done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a done callback argument which is not a function having a supported signature... -{ - whileAsync( predicate, fcn, 2 ); // $ExpectError - whileAsync( predicate, fcn, false ); // $ExpectError - whileAsync( predicate, fcn, true ); // $ExpectError - whileAsync( predicate, fcn, 'abc' ); // $ExpectError - whileAsync( predicate, fcn, {} ); // $ExpectError - whileAsync( predicate, fcn, [] ); // $ExpectError - whileAsync( predicate, fcn, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - whileAsync(); // $ExpectError - whileAsync( predicate ); // $ExpectError - whileAsync( predicate, fcn ); // $ExpectError - whileAsync( predicate, fcn, done, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a6af668..0000000 --- a/examples/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var repeatString = require( '@stdlib/string-repeat' ); -var whileAsync = require( './../lib' ); - -function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } -} - -function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, repeatString( 'beep', i+1 ) ); - } -} - -function done( error, result ) { - if ( error ) { - throw error; - } - console.log( result ); -} - -whileAsync( predicate, fcn, done ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..19136e1 --- /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-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";function n(n,e,i,o){var s,l;if(!r(n))throw new TypeError(t("0im3p",n));if(!r(e))throw new TypeError(t("0im2S",e));if(!r(i))throw new TypeError(t("0im3Z",i));function f(r,t){return r?i(r):t?e.call(o,l,m):(s.length&&s.unshift(null),void i.apply(null,s))}function m(r){var t;if(r)return i(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;gLA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,IAWnB,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,GAhDjBL,EAAO,GAEPJ,EADAK,EAAM,EACUI"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index f0719b2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Invoke a function while a test condition is true. -* -* @module @stdlib/utils-async-while -* -* @example -* var whileAsync = require( '@stdlib/utils-async-while' ); -* -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ - -// MODULES // - -var whileAsync = require( './while_async.js' ); - - -// EXPORTS // - -module.exports = whileAsync; diff --git a/lib/while_async.js b/lib/while_async.js deleted file mode 100644 index c03bb93..0000000 --- a/lib/while_async.js +++ /dev/null @@ -1,128 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Invokes a function while a test condition is true. -* -* @param {Function} predicate - function which indicates whether to continue invoking a function -* @param {Function} fcn - function to invoke -* @param {Callback} done - callback to invoke upon completion -* @param {*} [thisArg] - execution context for the invoked function -* @throws {TypeError} first argument must be a function -* @throws {TypeError} second argument must be a function -* @throws {TypeError} third argument must be a function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -function whileAsync( predicate, fcn, done, thisArg ) { - var args; - var idx; - if ( !isFunction( predicate ) ) { - throw new TypeError( format( '0im3p', predicate ) ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0im2S', fcn ) ); - } - if ( !isFunction( done ) ) { - throw new TypeError( format( '0im3Z', done ) ); - } - args = []; - idx = 0; - predicate( idx, onPredicate ); - - /** - * Callback invoked upon a predicate result. - * - * @private - * @param {(Error|null)} error - error object - * @param {boolean} result - predicate result - * @returns {void} - */ - function onPredicate( error, result ) { - if ( error ) { - return done( error ); - } - if ( result ) { - return fcn.call( thisArg, idx, next ); - } - if ( args.length ) { - args.unshift( null ); // error argument - } - done.apply( null, args ); - } - - /** - * Callback invoked upon completion of a provided function. - * - * @private - * @param {(Error|null)} error - error object - * @param {...*} results - function results - * @returns {void} - */ - function next( error ) { - var i; - if ( error ) { - return done( error ); - } - idx += 1; - - // Cache the most recent results... - if ( arguments.length > 1 ) { - args = new Array( arguments.length-1 ); - for ( i = 1; i < arguments.length; i++ ) { - args[ i-1 ] = arguments[ i ]; - } - } - // Run the test condition: - predicate( idx, onPredicate ); - } -} - - -// EXPORTS // - -module.exports = whileAsync; diff --git a/package.json b/package.json index fcdbeed..411f4ec 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Invoke a function while a test condition is true.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,35 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/bench": "^0.0.x", - "@stdlib/math-base-assert-is-nan": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "@stdlib/string-repeat": "^0.0.x", - "@stdlib/utils-noop": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..c64de0e --- /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 78d0688..0000000 --- a/test/test.js +++ /dev/null @@ -1,328 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 whileAsync = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof whileAsync, 'function', 'main export is a function' ); - t.end(); -}); - -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() { - whileAsync( value, noop, 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() { - whileAsync( noop, value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a callback 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() { - whileAsync( noop, noop, value ); - }; - } -}); - -tape( 'while a test condition is true, the function invokes a provided function', function test( t ) { - var indices1 = [ 0, 1, 2, 3, 4, 5 ]; - var indices2 = [ 0, 1, 2, 3, 4 ]; - var j = -1; - var k = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices1[ j ], 'provides expected value' ); - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - k += 1; - t.strictEqual( i, indices2[ k ], 'provides expected value' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'while a test condition is true, the function invokes a provided function (always false)', function test( t ) { - var indices = [ 0 ]; - var j = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices[ j ], 'provides expected value' ); - clbk( null, false ); - } - - function fcn( i, next ) { - t.fail( 'should never be invoked' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx = { - 'count': 0 - }; - - whileAsync( predicate, fcn, done, ctx ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - this.count += 1; // eslint-disable-line no-invalid-this - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( ctx.count, 5, 'updates context' ); - t.end(); - } -}); - -tape( 'the function provides any results to a `done` callback', function test( t ) { - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, 'beep'+i, 'boop'+i, 'woot'+i ); - } - } - - function done( error, str1, str2, str3 ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( str1, 'beep4', 'returns expected value' ); - t.strictEqual( str2, 'boop4', 'returns expected value' ); - t.strictEqual( str3, 'woot4', 'returns expected value' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the predicate function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - if ( i === 1 ) { - return clbk( new Error( 'beep' ) ); - } - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 2, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the provided function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - if ( i === 2 ) { - return next( new Error( 'boop' ) ); - } - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 3, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'the function does not guarantee asynchronous execution', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - k = 1; - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - next(); - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( k, 0, 'releases the zalgo' ); - t.end(); - } -}); From a2e5ea2a98fcfb9febb874156f6c829cc7c6878d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 5 Jul 2022 12:55:21 +0000 Subject: [PATCH 008/143] Transform error messages --- lib/while_async.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/while_async.js b/lib/while_async.js index 1dafc2a..c03bb93 100644 --- a/lib/while_async.js +++ b/lib/while_async.js @@ -21,7 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -62,13 +62,13 @@ function whileAsync( predicate, fcn, done, thisArg ) { var args; var idx; if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '0im3p', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0im2S', fcn ) ); } if ( !isFunction( done ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', done ) ); + throw new TypeError( format( '0im3Z', done ) ); } args = []; idx = 0; diff --git a/package.json b/package.json index db2fdb6..fcdbeed 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ }, "dependencies": { "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/string-format": "^0.0.x" + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/bench": "^0.0.x", From 10fd42bc9afc66707a691e09bc4214795c277c50 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 5 Jul 2022 14:05:06 +0000 Subject: [PATCH 009/143] Remove files --- index.d.ts | 127 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2821 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 b390f4c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,127 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Callback function. -*/ -type Nullary = () => void; - -/** -* Callback function. -* -* @param error - encountered error or null -*/ -type Unary = ( error: Error | null ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Binary = ( error: Error | null, bool: boolean ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Callback = Nullary | Unary | Binary; - -/** -* Callback invoked upon completion. -*/ -type DoneNullary = () => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -*/ -type DoneUnary = ( error: Error | null ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneBinary = ( error: Error | null, ...args: Array ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneCallback = DoneNullary | DoneUnary | DoneBinary; - -/** -* Checks whether an element in a collection passes a test. -* -* @param i - iteration number (starting from one) -* @param clbk - a callback indicating whether to invoke `fcn` -*/ -type Predicate = ( i: number, clbk: Callback ) => void; - -/** -* Invoked function. -* -* @param i - iteration number (starting from zero) -* @param next - a callback which must be invoked before proceeding to the next iteration -*/ -type Fcn = ( i: number, next: Function ) => void; - -/** -* Invokes a function while a test condition is true. -* -* @param predicate - function which indicates whether to continue invoking a function -* @param fcn - function to invoke -* @param done - callback to invoke upon completion -* @param thisArg - execution context for the invoked function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -declare function whileAsync( predicate: Predicate, fcn: Fcn, done: DoneCallback, thisArg?: any ): void; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = whileAsync; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 19136e1..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-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";function n(n,e,i,o){var s,l;if(!r(n))throw new TypeError(t("0im3p",n));if(!r(e))throw new TypeError(t("0im2S",e));if(!r(i))throw new TypeError(t("0im3Z",i));function f(r,t){return r?i(r):t?e.call(o,l,m):(s.length&&s.unshift(null),void i.apply(null,s))}function m(r){var t;if(r)return i(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;gLA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,IAWnB,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,GAhDjBL,EAAO,GAEPJ,EADAK,EAAM,EACUI"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index c64de0e..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From f069beffe885ec840a258bcda37ea9e0af079fe4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 5 Jul 2022 14:05:52 +0000 Subject: [PATCH 010/143] 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 | 105 - branches.md | 53 - docs/repl.txt | 72 - docs/types/test.ts | 83 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 57 - lib/while_async.js | 128 - package.json | 56 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 328 --- 36 files changed, 2714 insertions(+), 3764 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 (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/while_async.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 0f8dec8..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/async/while) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 d8c823e..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/async/while) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -279,7 +272,7 @@ whileAsync( predicate, fcn, done ); ## 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]. @@ -341,13 +334,13 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until +[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until/tree/esm -[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while +[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while/tree/esm -[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until +[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until/tree/esm -[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while +[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index ae9d749..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var whileAsync = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); - -bench( pkg+'::sync_predicate', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 576a70c..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/async/while" -click B href "https://github.com/stdlib-js/utils-async-while/tree/main" -click C href "https://github.com/stdlib-js/utils-async-while/tree/production" -click D href "https://github.com/stdlib-js/utils-async-while/tree/esm" -click E href "https://github.com/stdlib-js/utils-async-while/tree/deno" -click F href "https://github.com/stdlib-js/utils-async-while/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/async/while -[production-url]: https://github.com/stdlib-js/utils-async-while/tree/production -[deno-url]: https://github.com/stdlib-js/utils-async-while/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-async-while/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-async-while/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index d7ca8c9..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,72 +0,0 @@ - -{{alias}}( predicate, fcn, done[, thisArg] ) - Invokes a function while a test condition is true. - - The predicate function is provided two arguments: - - - `i`: iteration number (starting from zero) - - `clbk`: a callback indicating whether to invoke `fcn` - - The `clbk` function accepts two arguments: - - - `error`: error argument - - `bool`: test result - - If the test result is truthy, the function invokes `fcn`; otherwise, the - function invokes the `done` callback. - - The function to invoke is provided two arguments: - - - `i`: iteration number (starting from zero) - - `next`: a callback which must be invoked before proceeding to the next - iteration - - The first argument of the `next` callback is an `error` argument. If `fcn` - calls the `next` callback with a truthy `error` argument, the function - suspends execution and immediately calls the `done` callback for subsequent - `error` handling. - - The `done` callback is invoked with an `error` argument and any arguments - passed to the final `next` callback. - - Execution is *not* guaranteed to be asynchronous. To guarantee asynchrony, - wrap the `done` callback in a function which either executes at the end of - the current stack (e.g., `nextTick`) or during a subsequent turn of the - event loop (e.g., `setImmediate`, `setTimeout`). - - Parameters - ---------- - predicate: Function - The predicate function which indicates whether to continue invoking a - function. - - fcn: Function - The function to invoke. - - done: Function - Callback to invoke upon completion. - - thisArg: any (optional) - Execution context for the invoked function. - - Examples - -------- - > function predicate( i, clbk ) { clbk( null, i < 5 ); }; - > function fcn( i, next ) { - ... setTimeout( onTimeout, i ); - ... function onTimeout() { - ... next( null, 'boop'+i ); - ... } - ... }; - > function done( error, result ) { - ... if ( error ) { - ... throw error; - ... } - ... console.log( result ); - ... }; - > {{alias}}( predicate, fcn, done ) - boop: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4a543d9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,83 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 whileAsync = require( './index' ); - -const fcn = ( i: number, next: Function ): void => { - if ( i === void 0 ) { - throw new Error( '`i` is missing.' ); - } - next(); -}; - -const predicate = ( i: number, clbk: Function ): void => { - clbk( null, i < 5 ); -}; - -const done = ( error: Error | null ): void => { - if ( error ) { - throw error; - } -}; - - -// TESTS // - -// The function returns void... -{ - whileAsync( predicate, fcn, done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a predicate function... -{ - whileAsync( 2, fcn, done ); // $ExpectError - whileAsync( false, fcn, done ); // $ExpectError - whileAsync( true, fcn, done ); // $ExpectError - whileAsync( 'abc', fcn, done ); // $ExpectError - whileAsync( {}, fcn, done ); // $ExpectError - whileAsync( [], fcn, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function having a supported signature... -{ - whileAsync( predicate, 2, done ); // $ExpectError - whileAsync( predicate, false, done ); // $ExpectError - whileAsync( predicate, true, done ); // $ExpectError - whileAsync( predicate, 'abc', done ); // $ExpectError - whileAsync( predicate, {}, done ); // $ExpectError - whileAsync( predicate, [], done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a done callback argument which is not a function having a supported signature... -{ - whileAsync( predicate, fcn, 2 ); // $ExpectError - whileAsync( predicate, fcn, false ); // $ExpectError - whileAsync( predicate, fcn, true ); // $ExpectError - whileAsync( predicate, fcn, 'abc' ); // $ExpectError - whileAsync( predicate, fcn, {} ); // $ExpectError - whileAsync( predicate, fcn, [] ); // $ExpectError - whileAsync( predicate, fcn, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - whileAsync(); // $ExpectError - whileAsync( predicate ); // $ExpectError - whileAsync( predicate, fcn ); // $ExpectError - whileAsync( predicate, fcn, done, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a6af668..0000000 --- a/examples/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var repeatString = require( '@stdlib/string-repeat' ); -var whileAsync = require( './../lib' ); - -function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } -} - -function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, repeatString( 'beep', i+1 ) ); - } -} - -function done( error, result ) { - if ( error ) { - throw error; - } - console.log( result ); -} - -whileAsync( predicate, fcn, done ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..19136e1 --- /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-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";function n(n,e,i,o){var s,l;if(!r(n))throw new TypeError(t("0im3p",n));if(!r(e))throw new TypeError(t("0im2S",e));if(!r(i))throw new TypeError(t("0im3Z",i));function f(r,t){return r?i(r):t?e.call(o,l,m):(s.length&&s.unshift(null),void i.apply(null,s))}function m(r){var t;if(r)return i(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;gLA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,IAWnB,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,GAhDjBL,EAAO,GAEPJ,EADAK,EAAM,EACUI"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index f0719b2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Invoke a function while a test condition is true. -* -* @module @stdlib/utils-async-while -* -* @example -* var whileAsync = require( '@stdlib/utils-async-while' ); -* -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ - -// MODULES // - -var whileAsync = require( './while_async.js' ); - - -// EXPORTS // - -module.exports = whileAsync; diff --git a/lib/while_async.js b/lib/while_async.js deleted file mode 100644 index c03bb93..0000000 --- a/lib/while_async.js +++ /dev/null @@ -1,128 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Invokes a function while a test condition is true. -* -* @param {Function} predicate - function which indicates whether to continue invoking a function -* @param {Function} fcn - function to invoke -* @param {Callback} done - callback to invoke upon completion -* @param {*} [thisArg] - execution context for the invoked function -* @throws {TypeError} first argument must be a function -* @throws {TypeError} second argument must be a function -* @throws {TypeError} third argument must be a function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -function whileAsync( predicate, fcn, done, thisArg ) { - var args; - var idx; - if ( !isFunction( predicate ) ) { - throw new TypeError( format( '0im3p', predicate ) ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0im2S', fcn ) ); - } - if ( !isFunction( done ) ) { - throw new TypeError( format( '0im3Z', done ) ); - } - args = []; - idx = 0; - predicate( idx, onPredicate ); - - /** - * Callback invoked upon a predicate result. - * - * @private - * @param {(Error|null)} error - error object - * @param {boolean} result - predicate result - * @returns {void} - */ - function onPredicate( error, result ) { - if ( error ) { - return done( error ); - } - if ( result ) { - return fcn.call( thisArg, idx, next ); - } - if ( args.length ) { - args.unshift( null ); // error argument - } - done.apply( null, args ); - } - - /** - * Callback invoked upon completion of a provided function. - * - * @private - * @param {(Error|null)} error - error object - * @param {...*} results - function results - * @returns {void} - */ - function next( error ) { - var i; - if ( error ) { - return done( error ); - } - idx += 1; - - // Cache the most recent results... - if ( arguments.length > 1 ) { - args = new Array( arguments.length-1 ); - for ( i = 1; i < arguments.length; i++ ) { - args[ i-1 ] = arguments[ i ]; - } - } - // Run the test condition: - predicate( idx, onPredicate ); - } -} - - -// EXPORTS // - -module.exports = whileAsync; diff --git a/package.json b/package.json index fcdbeed..411f4ec 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Invoke a function while a test condition is true.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,35 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/bench": "^0.0.x", - "@stdlib/math-base-assert-is-nan": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "@stdlib/string-repeat": "^0.0.x", - "@stdlib/utils-noop": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..62e7988 --- /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 78d0688..0000000 --- a/test/test.js +++ /dev/null @@ -1,328 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 whileAsync = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof whileAsync, 'function', 'main export is a function' ); - t.end(); -}); - -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() { - whileAsync( value, noop, 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() { - whileAsync( noop, value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a callback 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() { - whileAsync( noop, noop, value ); - }; - } -}); - -tape( 'while a test condition is true, the function invokes a provided function', function test( t ) { - var indices1 = [ 0, 1, 2, 3, 4, 5 ]; - var indices2 = [ 0, 1, 2, 3, 4 ]; - var j = -1; - var k = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices1[ j ], 'provides expected value' ); - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - k += 1; - t.strictEqual( i, indices2[ k ], 'provides expected value' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'while a test condition is true, the function invokes a provided function (always false)', function test( t ) { - var indices = [ 0 ]; - var j = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices[ j ], 'provides expected value' ); - clbk( null, false ); - } - - function fcn( i, next ) { - t.fail( 'should never be invoked' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx = { - 'count': 0 - }; - - whileAsync( predicate, fcn, done, ctx ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - this.count += 1; // eslint-disable-line no-invalid-this - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( ctx.count, 5, 'updates context' ); - t.end(); - } -}); - -tape( 'the function provides any results to a `done` callback', function test( t ) { - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, 'beep'+i, 'boop'+i, 'woot'+i ); - } - } - - function done( error, str1, str2, str3 ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( str1, 'beep4', 'returns expected value' ); - t.strictEqual( str2, 'boop4', 'returns expected value' ); - t.strictEqual( str3, 'woot4', 'returns expected value' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the predicate function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - if ( i === 1 ) { - return clbk( new Error( 'beep' ) ); - } - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 2, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the provided function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - if ( i === 2 ) { - return next( new Error( 'boop' ) ); - } - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 3, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'the function does not guarantee asynchronous execution', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - k = 1; - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - next(); - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( k, 0, 'releases the zalgo' ); - t.end(); - } -}); From afd2947aece1bc08ee0a85bbb29d0a31f2339867 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 03:36:13 +0000 Subject: [PATCH 011/143] Transform error messages --- lib/while_async.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/while_async.js b/lib/while_async.js index 1dafc2a..c03bb93 100644 --- a/lib/while_async.js +++ b/lib/while_async.js @@ -21,7 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -62,13 +62,13 @@ function whileAsync( predicate, fcn, done, thisArg ) { var args; var idx; if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '0im3p', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0im2S', fcn ) ); } if ( !isFunction( done ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', done ) ); + throw new TypeError( format( '0im3Z', done ) ); } args = []; idx = 0; diff --git a/package.json b/package.json index db2fdb6..fcdbeed 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ }, "dependencies": { "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/string-format": "^0.0.x" + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/bench": "^0.0.x", From a10badd2c4555abe6f86cf401b0350fde28fa768 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 17:16:22 +0000 Subject: [PATCH 012/143] Remove files --- index.d.ts | 127 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2821 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 b390f4c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,127 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Callback function. -*/ -type Nullary = () => void; - -/** -* Callback function. -* -* @param error - encountered error or null -*/ -type Unary = ( error: Error | null ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Binary = ( error: Error | null, bool: boolean ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Callback = Nullary | Unary | Binary; - -/** -* Callback invoked upon completion. -*/ -type DoneNullary = () => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -*/ -type DoneUnary = ( error: Error | null ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneBinary = ( error: Error | null, ...args: Array ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneCallback = DoneNullary | DoneUnary | DoneBinary; - -/** -* Checks whether an element in a collection passes a test. -* -* @param i - iteration number (starting from one) -* @param clbk - a callback indicating whether to invoke `fcn` -*/ -type Predicate = ( i: number, clbk: Callback ) => void; - -/** -* Invoked function. -* -* @param i - iteration number (starting from zero) -* @param next - a callback which must be invoked before proceeding to the next iteration -*/ -type Fcn = ( i: number, next: Function ) => void; - -/** -* Invokes a function while a test condition is true. -* -* @param predicate - function which indicates whether to continue invoking a function -* @param fcn - function to invoke -* @param done - callback to invoke upon completion -* @param thisArg - execution context for the invoked function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -declare function whileAsync( predicate: Predicate, fcn: Fcn, done: DoneCallback, thisArg?: any ): void; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = whileAsync; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 19136e1..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-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";function n(n,e,i,o){var s,l;if(!r(n))throw new TypeError(t("0im3p",n));if(!r(e))throw new TypeError(t("0im2S",e));if(!r(i))throw new TypeError(t("0im3Z",i));function f(r,t){return r?i(r):t?e.call(o,l,m):(s.length&&s.unshift(null),void i.apply(null,s))}function m(r){var t;if(r)return i(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;gLA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,IAWnB,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,GAhDjBL,EAAO,GAEPJ,EADAK,EAAM,EACUI"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 62e7988..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 3e838ee6f066d228ebef94427fe229b3a8561788 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 17:17:05 +0000 Subject: [PATCH 013/143] 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 | 105 - branches.md | 53 - docs/repl.txt | 72 - docs/types/test.ts | 83 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 57 - lib/while_async.js | 128 - package.json | 56 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 328 --- 37 files changed, 2714 insertions(+), 3838 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 (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/while_async.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 ffb7a9d..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-08-01T00:45:57.043Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 0f8dec8..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/async/while) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 d8c823e..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/async/while) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -279,7 +272,7 @@ whileAsync( predicate, fcn, done ); ## 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]. @@ -341,13 +334,13 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until +[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until/tree/esm -[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while +[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while/tree/esm -[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until +[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until/tree/esm -[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while +[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index ae9d749..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var whileAsync = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); - -bench( pkg+'::sync_predicate', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 576a70c..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/async/while" -click B href "https://github.com/stdlib-js/utils-async-while/tree/main" -click C href "https://github.com/stdlib-js/utils-async-while/tree/production" -click D href "https://github.com/stdlib-js/utils-async-while/tree/esm" -click E href "https://github.com/stdlib-js/utils-async-while/tree/deno" -click F href "https://github.com/stdlib-js/utils-async-while/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/async/while -[production-url]: https://github.com/stdlib-js/utils-async-while/tree/production -[deno-url]: https://github.com/stdlib-js/utils-async-while/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-async-while/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-async-while/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index d7ca8c9..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,72 +0,0 @@ - -{{alias}}( predicate, fcn, done[, thisArg] ) - Invokes a function while a test condition is true. - - The predicate function is provided two arguments: - - - `i`: iteration number (starting from zero) - - `clbk`: a callback indicating whether to invoke `fcn` - - The `clbk` function accepts two arguments: - - - `error`: error argument - - `bool`: test result - - If the test result is truthy, the function invokes `fcn`; otherwise, the - function invokes the `done` callback. - - The function to invoke is provided two arguments: - - - `i`: iteration number (starting from zero) - - `next`: a callback which must be invoked before proceeding to the next - iteration - - The first argument of the `next` callback is an `error` argument. If `fcn` - calls the `next` callback with a truthy `error` argument, the function - suspends execution and immediately calls the `done` callback for subsequent - `error` handling. - - The `done` callback is invoked with an `error` argument and any arguments - passed to the final `next` callback. - - Execution is *not* guaranteed to be asynchronous. To guarantee asynchrony, - wrap the `done` callback in a function which either executes at the end of - the current stack (e.g., `nextTick`) or during a subsequent turn of the - event loop (e.g., `setImmediate`, `setTimeout`). - - Parameters - ---------- - predicate: Function - The predicate function which indicates whether to continue invoking a - function. - - fcn: Function - The function to invoke. - - done: Function - Callback to invoke upon completion. - - thisArg: any (optional) - Execution context for the invoked function. - - Examples - -------- - > function predicate( i, clbk ) { clbk( null, i < 5 ); }; - > function fcn( i, next ) { - ... setTimeout( onTimeout, i ); - ... function onTimeout() { - ... next( null, 'boop'+i ); - ... } - ... }; - > function done( error, result ) { - ... if ( error ) { - ... throw error; - ... } - ... console.log( result ); - ... }; - > {{alias}}( predicate, fcn, done ) - boop: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4a543d9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,83 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 whileAsync = require( './index' ); - -const fcn = ( i: number, next: Function ): void => { - if ( i === void 0 ) { - throw new Error( '`i` is missing.' ); - } - next(); -}; - -const predicate = ( i: number, clbk: Function ): void => { - clbk( null, i < 5 ); -}; - -const done = ( error: Error | null ): void => { - if ( error ) { - throw error; - } -}; - - -// TESTS // - -// The function returns void... -{ - whileAsync( predicate, fcn, done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a predicate function... -{ - whileAsync( 2, fcn, done ); // $ExpectError - whileAsync( false, fcn, done ); // $ExpectError - whileAsync( true, fcn, done ); // $ExpectError - whileAsync( 'abc', fcn, done ); // $ExpectError - whileAsync( {}, fcn, done ); // $ExpectError - whileAsync( [], fcn, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function having a supported signature... -{ - whileAsync( predicate, 2, done ); // $ExpectError - whileAsync( predicate, false, done ); // $ExpectError - whileAsync( predicate, true, done ); // $ExpectError - whileAsync( predicate, 'abc', done ); // $ExpectError - whileAsync( predicate, {}, done ); // $ExpectError - whileAsync( predicate, [], done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a done callback argument which is not a function having a supported signature... -{ - whileAsync( predicate, fcn, 2 ); // $ExpectError - whileAsync( predicate, fcn, false ); // $ExpectError - whileAsync( predicate, fcn, true ); // $ExpectError - whileAsync( predicate, fcn, 'abc' ); // $ExpectError - whileAsync( predicate, fcn, {} ); // $ExpectError - whileAsync( predicate, fcn, [] ); // $ExpectError - whileAsync( predicate, fcn, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - whileAsync(); // $ExpectError - whileAsync( predicate ); // $ExpectError - whileAsync( predicate, fcn ); // $ExpectError - whileAsync( predicate, fcn, done, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a6af668..0000000 --- a/examples/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var repeatString = require( '@stdlib/string-repeat' ); -var whileAsync = require( './../lib' ); - -function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } -} - -function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, repeatString( 'beep', i+1 ) ); - } -} - -function done( error, result ) { - if ( error ) { - throw error; - } - console.log( result ); -} - -whileAsync( predicate, fcn, done ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..b4c4a89 --- /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-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,e,i,o){var s,l;if(!r(n))throw new TypeError(t("0im3p",n));if(!r(e))throw new TypeError(t("0im2S",e));if(!r(i))throw new TypeError(t("0im3Z",i));function f(r,t){return r?i(r):t?e.call(o,l,m):(s.length&&s.unshift(null),void i.apply(null,s))}function m(r){var t;if(r)return i(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;uLA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,IAWnB,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,GAhDjBL,EAAO,GAEPJ,EADAK,EAAM,EACUI"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index f0719b2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Invoke a function while a test condition is true. -* -* @module @stdlib/utils-async-while -* -* @example -* var whileAsync = require( '@stdlib/utils-async-while' ); -* -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ - -// MODULES // - -var whileAsync = require( './while_async.js' ); - - -// EXPORTS // - -module.exports = whileAsync; diff --git a/lib/while_async.js b/lib/while_async.js deleted file mode 100644 index c03bb93..0000000 --- a/lib/while_async.js +++ /dev/null @@ -1,128 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Invokes a function while a test condition is true. -* -* @param {Function} predicate - function which indicates whether to continue invoking a function -* @param {Function} fcn - function to invoke -* @param {Callback} done - callback to invoke upon completion -* @param {*} [thisArg] - execution context for the invoked function -* @throws {TypeError} first argument must be a function -* @throws {TypeError} second argument must be a function -* @throws {TypeError} third argument must be a function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -function whileAsync( predicate, fcn, done, thisArg ) { - var args; - var idx; - if ( !isFunction( predicate ) ) { - throw new TypeError( format( '0im3p', predicate ) ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0im2S', fcn ) ); - } - if ( !isFunction( done ) ) { - throw new TypeError( format( '0im3Z', done ) ); - } - args = []; - idx = 0; - predicate( idx, onPredicate ); - - /** - * Callback invoked upon a predicate result. - * - * @private - * @param {(Error|null)} error - error object - * @param {boolean} result - predicate result - * @returns {void} - */ - function onPredicate( error, result ) { - if ( error ) { - return done( error ); - } - if ( result ) { - return fcn.call( thisArg, idx, next ); - } - if ( args.length ) { - args.unshift( null ); // error argument - } - done.apply( null, args ); - } - - /** - * Callback invoked upon completion of a provided function. - * - * @private - * @param {(Error|null)} error - error object - * @param {...*} results - function results - * @returns {void} - */ - function next( error ) { - var i; - if ( error ) { - return done( error ); - } - idx += 1; - - // Cache the most recent results... - if ( arguments.length > 1 ) { - args = new Array( arguments.length-1 ); - for ( i = 1; i < arguments.length; i++ ) { - args[ i-1 ] = arguments[ i ]; - } - } - // Run the test condition: - predicate( idx, onPredicate ); - } -} - - -// EXPORTS // - -module.exports = whileAsync; diff --git a/package.json b/package.json index fcdbeed..411f4ec 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Invoke a function while a test condition is true.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,35 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/bench": "^0.0.x", - "@stdlib/math-base-assert-is-nan": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "@stdlib/string-repeat": "^0.0.x", - "@stdlib/utils-noop": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..13afd10 --- /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 78d0688..0000000 --- a/test/test.js +++ /dev/null @@ -1,328 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 whileAsync = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof whileAsync, 'function', 'main export is a function' ); - t.end(); -}); - -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() { - whileAsync( value, noop, 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() { - whileAsync( noop, value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a callback 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() { - whileAsync( noop, noop, value ); - }; - } -}); - -tape( 'while a test condition is true, the function invokes a provided function', function test( t ) { - var indices1 = [ 0, 1, 2, 3, 4, 5 ]; - var indices2 = [ 0, 1, 2, 3, 4 ]; - var j = -1; - var k = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices1[ j ], 'provides expected value' ); - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - k += 1; - t.strictEqual( i, indices2[ k ], 'provides expected value' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'while a test condition is true, the function invokes a provided function (always false)', function test( t ) { - var indices = [ 0 ]; - var j = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices[ j ], 'provides expected value' ); - clbk( null, false ); - } - - function fcn( i, next ) { - t.fail( 'should never be invoked' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx = { - 'count': 0 - }; - - whileAsync( predicate, fcn, done, ctx ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - this.count += 1; // eslint-disable-line no-invalid-this - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( ctx.count, 5, 'updates context' ); - t.end(); - } -}); - -tape( 'the function provides any results to a `done` callback', function test( t ) { - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, 'beep'+i, 'boop'+i, 'woot'+i ); - } - } - - function done( error, str1, str2, str3 ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( str1, 'beep4', 'returns expected value' ); - t.strictEqual( str2, 'boop4', 'returns expected value' ); - t.strictEqual( str3, 'woot4', 'returns expected value' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the predicate function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - if ( i === 1 ) { - return clbk( new Error( 'beep' ) ); - } - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 2, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the provided function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - if ( i === 2 ) { - return next( new Error( 'boop' ) ); - } - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 3, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'the function does not guarantee asynchronous execution', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - k = 1; - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - next(); - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( k, 0, 'releases the zalgo' ); - t.end(); - } -}); From 13218874f9a15c60f6651fee2fd5f8f40fd59e91 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 03:19:40 +0000 Subject: [PATCH 014/143] Transform error messages --- lib/while_async.js | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/while_async.js b/lib/while_async.js index 1dafc2a..c03bb93 100644 --- a/lib/while_async.js +++ b/lib/while_async.js @@ -21,7 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -62,13 +62,13 @@ function whileAsync( predicate, fcn, done, thisArg ) { var args; var idx; if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '0im3p', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0im2S', fcn ) ); } if ( !isFunction( done ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', done ) ); + throw new TypeError( format( '0im3Z', done ) ); } args = []; idx = 0; diff --git a/package.json b/package.json index db2fdb6..fcdbeed 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ }, "dependencies": { "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/string-format": "^0.0.x" + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/bench": "^0.0.x", From dc3f0d0da0ad9cfe0b6538f3d6d7b2a948039924 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 13:10:52 +0000 Subject: [PATCH 015/143] Remove files --- index.d.ts | 127 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2821 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 b390f4c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,127 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Callback function. -*/ -type Nullary = () => void; - -/** -* Callback function. -* -* @param error - encountered error or null -*/ -type Unary = ( error: Error | null ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Binary = ( error: Error | null, bool: boolean ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Callback = Nullary | Unary | Binary; - -/** -* Callback invoked upon completion. -*/ -type DoneNullary = () => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -*/ -type DoneUnary = ( error: Error | null ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneBinary = ( error: Error | null, ...args: Array ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneCallback = DoneNullary | DoneUnary | DoneBinary; - -/** -* Checks whether an element in a collection passes a test. -* -* @param i - iteration number (starting from one) -* @param clbk - a callback indicating whether to invoke `fcn` -*/ -type Predicate = ( i: number, clbk: Callback ) => void; - -/** -* Invoked function. -* -* @param i - iteration number (starting from zero) -* @param next - a callback which must be invoked before proceeding to the next iteration -*/ -type Fcn = ( i: number, next: Function ) => void; - -/** -* Invokes a function while a test condition is true. -* -* @param predicate - function which indicates whether to continue invoking a function -* @param fcn - function to invoke -* @param done - callback to invoke upon completion -* @param thisArg - execution context for the invoked function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -declare function whileAsync( predicate: Predicate, fcn: Fcn, done: DoneCallback, thisArg?: any ): void; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = whileAsync; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b4c4a89..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-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,e,i,o){var s,l;if(!r(n))throw new TypeError(t("0im3p",n));if(!r(e))throw new TypeError(t("0im2S",e));if(!r(i))throw new TypeError(t("0im3Z",i));function f(r,t){return r?i(r):t?e.call(o,l,m):(s.length&&s.unshift(null),void i.apply(null,s))}function m(r){var t;if(r)return i(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;uLA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,IAWnB,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,GAhDjBL,EAAO,GAEPJ,EADAK,EAAM,EACUI"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 13afd10..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 7c5fe009798f731199b71eaa056759caeaa37d18 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 13:11:51 +0000 Subject: [PATCH 016/143] 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 | 105 - branches.md | 53 - docs/repl.txt | 72 - docs/types/test.ts | 83 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 57 - lib/while_async.js | 128 - package.json | 56 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 328 --- 37 files changed, 2714 insertions(+), 3854 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 (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/while_async.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 f3af61e..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-09-01T00:41:25.614Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 0f8dec8..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/async/while) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 d8c823e..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/async/while) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -279,7 +272,7 @@ whileAsync( predicate, fcn, done ); ## 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]. @@ -341,13 +334,13 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until +[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until/tree/esm -[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while +[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while/tree/esm -[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until +[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until/tree/esm -[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while +[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index ae9d749..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var whileAsync = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); - -bench( pkg+'::sync_predicate', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 576a70c..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/async/while" -click B href "https://github.com/stdlib-js/utils-async-while/tree/main" -click C href "https://github.com/stdlib-js/utils-async-while/tree/production" -click D href "https://github.com/stdlib-js/utils-async-while/tree/esm" -click E href "https://github.com/stdlib-js/utils-async-while/tree/deno" -click F href "https://github.com/stdlib-js/utils-async-while/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/async/while -[production-url]: https://github.com/stdlib-js/utils-async-while/tree/production -[deno-url]: https://github.com/stdlib-js/utils-async-while/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-async-while/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-async-while/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index d7ca8c9..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,72 +0,0 @@ - -{{alias}}( predicate, fcn, done[, thisArg] ) - Invokes a function while a test condition is true. - - The predicate function is provided two arguments: - - - `i`: iteration number (starting from zero) - - `clbk`: a callback indicating whether to invoke `fcn` - - The `clbk` function accepts two arguments: - - - `error`: error argument - - `bool`: test result - - If the test result is truthy, the function invokes `fcn`; otherwise, the - function invokes the `done` callback. - - The function to invoke is provided two arguments: - - - `i`: iteration number (starting from zero) - - `next`: a callback which must be invoked before proceeding to the next - iteration - - The first argument of the `next` callback is an `error` argument. If `fcn` - calls the `next` callback with a truthy `error` argument, the function - suspends execution and immediately calls the `done` callback for subsequent - `error` handling. - - The `done` callback is invoked with an `error` argument and any arguments - passed to the final `next` callback. - - Execution is *not* guaranteed to be asynchronous. To guarantee asynchrony, - wrap the `done` callback in a function which either executes at the end of - the current stack (e.g., `nextTick`) or during a subsequent turn of the - event loop (e.g., `setImmediate`, `setTimeout`). - - Parameters - ---------- - predicate: Function - The predicate function which indicates whether to continue invoking a - function. - - fcn: Function - The function to invoke. - - done: Function - Callback to invoke upon completion. - - thisArg: any (optional) - Execution context for the invoked function. - - Examples - -------- - > function predicate( i, clbk ) { clbk( null, i < 5 ); }; - > function fcn( i, next ) { - ... setTimeout( onTimeout, i ); - ... function onTimeout() { - ... next( null, 'boop'+i ); - ... } - ... }; - > function done( error, result ) { - ... if ( error ) { - ... throw error; - ... } - ... console.log( result ); - ... }; - > {{alias}}( predicate, fcn, done ) - boop: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4a543d9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,83 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 whileAsync = require( './index' ); - -const fcn = ( i: number, next: Function ): void => { - if ( i === void 0 ) { - throw new Error( '`i` is missing.' ); - } - next(); -}; - -const predicate = ( i: number, clbk: Function ): void => { - clbk( null, i < 5 ); -}; - -const done = ( error: Error | null ): void => { - if ( error ) { - throw error; - } -}; - - -// TESTS // - -// The function returns void... -{ - whileAsync( predicate, fcn, done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a predicate function... -{ - whileAsync( 2, fcn, done ); // $ExpectError - whileAsync( false, fcn, done ); // $ExpectError - whileAsync( true, fcn, done ); // $ExpectError - whileAsync( 'abc', fcn, done ); // $ExpectError - whileAsync( {}, fcn, done ); // $ExpectError - whileAsync( [], fcn, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function having a supported signature... -{ - whileAsync( predicate, 2, done ); // $ExpectError - whileAsync( predicate, false, done ); // $ExpectError - whileAsync( predicate, true, done ); // $ExpectError - whileAsync( predicate, 'abc', done ); // $ExpectError - whileAsync( predicate, {}, done ); // $ExpectError - whileAsync( predicate, [], done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a done callback argument which is not a function having a supported signature... -{ - whileAsync( predicate, fcn, 2 ); // $ExpectError - whileAsync( predicate, fcn, false ); // $ExpectError - whileAsync( predicate, fcn, true ); // $ExpectError - whileAsync( predicate, fcn, 'abc' ); // $ExpectError - whileAsync( predicate, fcn, {} ); // $ExpectError - whileAsync( predicate, fcn, [] ); // $ExpectError - whileAsync( predicate, fcn, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - whileAsync(); // $ExpectError - whileAsync( predicate ); // $ExpectError - whileAsync( predicate, fcn ); // $ExpectError - whileAsync( predicate, fcn, done, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a6af668..0000000 --- a/examples/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var repeatString = require( '@stdlib/string-repeat' ); -var whileAsync = require( './../lib' ); - -function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } -} - -function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, repeatString( 'beep', i+1 ) ); - } -} - -function done( error, result ) { - if ( error ) { - throw error; - } - console.log( result ); -} - -whileAsync( predicate, fcn, done ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..b4c4a89 --- /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-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,e,i,o){var s,l;if(!r(n))throw new TypeError(t("0im3p",n));if(!r(e))throw new TypeError(t("0im2S",e));if(!r(i))throw new TypeError(t("0im3Z",i));function f(r,t){return r?i(r):t?e.call(o,l,m):(s.length&&s.unshift(null),void i.apply(null,s))}function m(r){var t;if(r)return i(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;uLA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,IAWnB,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,GAhDjBL,EAAO,GAEPJ,EADAK,EAAM,EACUI"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index f0719b2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Invoke a function while a test condition is true. -* -* @module @stdlib/utils-async-while -* -* @example -* var whileAsync = require( '@stdlib/utils-async-while' ); -* -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ - -// MODULES // - -var whileAsync = require( './while_async.js' ); - - -// EXPORTS // - -module.exports = whileAsync; diff --git a/lib/while_async.js b/lib/while_async.js deleted file mode 100644 index c03bb93..0000000 --- a/lib/while_async.js +++ /dev/null @@ -1,128 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Invokes a function while a test condition is true. -* -* @param {Function} predicate - function which indicates whether to continue invoking a function -* @param {Function} fcn - function to invoke -* @param {Callback} done - callback to invoke upon completion -* @param {*} [thisArg] - execution context for the invoked function -* @throws {TypeError} first argument must be a function -* @throws {TypeError} second argument must be a function -* @throws {TypeError} third argument must be a function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -function whileAsync( predicate, fcn, done, thisArg ) { - var args; - var idx; - if ( !isFunction( predicate ) ) { - throw new TypeError( format( '0im3p', predicate ) ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0im2S', fcn ) ); - } - if ( !isFunction( done ) ) { - throw new TypeError( format( '0im3Z', done ) ); - } - args = []; - idx = 0; - predicate( idx, onPredicate ); - - /** - * Callback invoked upon a predicate result. - * - * @private - * @param {(Error|null)} error - error object - * @param {boolean} result - predicate result - * @returns {void} - */ - function onPredicate( error, result ) { - if ( error ) { - return done( error ); - } - if ( result ) { - return fcn.call( thisArg, idx, next ); - } - if ( args.length ) { - args.unshift( null ); // error argument - } - done.apply( null, args ); - } - - /** - * Callback invoked upon completion of a provided function. - * - * @private - * @param {(Error|null)} error - error object - * @param {...*} results - function results - * @returns {void} - */ - function next( error ) { - var i; - if ( error ) { - return done( error ); - } - idx += 1; - - // Cache the most recent results... - if ( arguments.length > 1 ) { - args = new Array( arguments.length-1 ); - for ( i = 1; i < arguments.length; i++ ) { - args[ i-1 ] = arguments[ i ]; - } - } - // Run the test condition: - predicate( idx, onPredicate ); - } -} - - -// EXPORTS // - -module.exports = whileAsync; diff --git a/package.json b/package.json index fcdbeed..411f4ec 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Invoke a function while a test condition is true.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,35 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/bench": "^0.0.x", - "@stdlib/math-base-assert-is-nan": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "@stdlib/string-repeat": "^0.0.x", - "@stdlib/utils-noop": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..0e43923 --- /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 78d0688..0000000 --- a/test/test.js +++ /dev/null @@ -1,328 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 whileAsync = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof whileAsync, 'function', 'main export is a function' ); - t.end(); -}); - -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() { - whileAsync( value, noop, 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() { - whileAsync( noop, value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a callback 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() { - whileAsync( noop, noop, value ); - }; - } -}); - -tape( 'while a test condition is true, the function invokes a provided function', function test( t ) { - var indices1 = [ 0, 1, 2, 3, 4, 5 ]; - var indices2 = [ 0, 1, 2, 3, 4 ]; - var j = -1; - var k = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices1[ j ], 'provides expected value' ); - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - k += 1; - t.strictEqual( i, indices2[ k ], 'provides expected value' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'while a test condition is true, the function invokes a provided function (always false)', function test( t ) { - var indices = [ 0 ]; - var j = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices[ j ], 'provides expected value' ); - clbk( null, false ); - } - - function fcn( i, next ) { - t.fail( 'should never be invoked' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx = { - 'count': 0 - }; - - whileAsync( predicate, fcn, done, ctx ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - this.count += 1; // eslint-disable-line no-invalid-this - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( ctx.count, 5, 'updates context' ); - t.end(); - } -}); - -tape( 'the function provides any results to a `done` callback', function test( t ) { - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, 'beep'+i, 'boop'+i, 'woot'+i ); - } - } - - function done( error, str1, str2, str3 ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( str1, 'beep4', 'returns expected value' ); - t.strictEqual( str2, 'boop4', 'returns expected value' ); - t.strictEqual( str3, 'woot4', 'returns expected value' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the predicate function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - if ( i === 1 ) { - return clbk( new Error( 'beep' ) ); - } - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 2, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the provided function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - if ( i === 2 ) { - return next( new Error( 'boop' ) ); - } - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 3, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'the function does not guarantee asynchronous execution', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - k = 1; - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - next(); - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( k, 0, 'releases the zalgo' ); - t.end(); - } -}); From 1eef166a91a49bffb00df827ef36f2e8546d8785 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Sep 2022 01:23:34 +0000 Subject: [PATCH 017/143] 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 1dafc2a..c03bb93 100644 --- a/lib/main.js +++ b/lib/main.js @@ -21,7 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -62,13 +62,13 @@ function whileAsync( predicate, fcn, done, thisArg ) { var args; var idx; if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '0im3p', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0im2S', fcn ) ); } if ( !isFunction( done ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', done ) ); + throw new TypeError( format( '0im3Z', done ) ); } args = []; idx = 0; diff --git a/package.json b/package.json index db2fdb6..fcdbeed 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ }, "dependencies": { "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/string-format": "^0.0.x" + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/bench": "^0.0.x", From e98edac32b69c426c74870222fed0abace1d59df Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Sep 2022 01:50:48 +0000 Subject: [PATCH 018/143] Remove files --- index.d.ts | 127 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2821 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 b390f4c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,127 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Callback function. -*/ -type Nullary = () => void; - -/** -* Callback function. -* -* @param error - encountered error or null -*/ -type Unary = ( error: Error | null ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Binary = ( error: Error | null, bool: boolean ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Callback = Nullary | Unary | Binary; - -/** -* Callback invoked upon completion. -*/ -type DoneNullary = () => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -*/ -type DoneUnary = ( error: Error | null ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneBinary = ( error: Error | null, ...args: Array ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneCallback = DoneNullary | DoneUnary | DoneBinary; - -/** -* Checks whether an element in a collection passes a test. -* -* @param i - iteration number (starting from one) -* @param clbk - a callback indicating whether to invoke `fcn` -*/ -type Predicate = ( i: number, clbk: Callback ) => void; - -/** -* Invoked function. -* -* @param i - iteration number (starting from zero) -* @param next - a callback which must be invoked before proceeding to the next iteration -*/ -type Fcn = ( i: number, next: Function ) => void; - -/** -* Invokes a function while a test condition is true. -* -* @param predicate - function which indicates whether to continue invoking a function -* @param fcn - function to invoke -* @param done - callback to invoke upon completion -* @param thisArg - execution context for the invoked function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -declare function whileAsync( predicate: Predicate, fcn: Fcn, done: DoneCallback, thisArg?: any ): void; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = whileAsync; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b4c4a89..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-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,e,i,o){var s,l;if(!r(n))throw new TypeError(t("0im3p",n));if(!r(e))throw new TypeError(t("0im2S",e));if(!r(i))throw new TypeError(t("0im3Z",i));function f(r,t){return r?i(r):t?e.call(o,l,m):(s.length&&s.unshift(null),void i.apply(null,s))}function m(r){var t;if(r)return i(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;uLA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,IAWnB,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,GAhDjBL,EAAO,GAEPJ,EADAK,EAAM,EACUI"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 0e43923..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 0379787f6941e82f9cfd557e022b146f3f897bf4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Sep 2022 01:51:33 +0000 Subject: [PATCH 019/143] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 760 ------ .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 43 +- benchmark/benchmark.js | 105 - branches.md | 53 - docs/repl.txt | 72 - docs/types/test.ts | 83 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 57 - lib/main.js | 128 - package.json | 56 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 328 --- 36 files changed, 2714 insertions(+), 3853 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 (100%) 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 0f8dec8..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/async/while) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 d8c823e..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/async/while) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -279,7 +272,7 @@ whileAsync( predicate, fcn, done ); ## 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]. @@ -341,13 +334,13 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until +[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until/tree/esm -[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while +[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while/tree/esm -[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until +[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until/tree/esm -[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while +[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index ae9d749..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var whileAsync = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); - -bench( pkg+'::sync_predicate', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 576a70c..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/async/while" -click B href "https://github.com/stdlib-js/utils-async-while/tree/main" -click C href "https://github.com/stdlib-js/utils-async-while/tree/production" -click D href "https://github.com/stdlib-js/utils-async-while/tree/esm" -click E href "https://github.com/stdlib-js/utils-async-while/tree/deno" -click F href "https://github.com/stdlib-js/utils-async-while/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/async/while -[production-url]: https://github.com/stdlib-js/utils-async-while/tree/production -[deno-url]: https://github.com/stdlib-js/utils-async-while/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-async-while/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-async-while/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index d7ca8c9..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,72 +0,0 @@ - -{{alias}}( predicate, fcn, done[, thisArg] ) - Invokes a function while a test condition is true. - - The predicate function is provided two arguments: - - - `i`: iteration number (starting from zero) - - `clbk`: a callback indicating whether to invoke `fcn` - - The `clbk` function accepts two arguments: - - - `error`: error argument - - `bool`: test result - - If the test result is truthy, the function invokes `fcn`; otherwise, the - function invokes the `done` callback. - - The function to invoke is provided two arguments: - - - `i`: iteration number (starting from zero) - - `next`: a callback which must be invoked before proceeding to the next - iteration - - The first argument of the `next` callback is an `error` argument. If `fcn` - calls the `next` callback with a truthy `error` argument, the function - suspends execution and immediately calls the `done` callback for subsequent - `error` handling. - - The `done` callback is invoked with an `error` argument and any arguments - passed to the final `next` callback. - - Execution is *not* guaranteed to be asynchronous. To guarantee asynchrony, - wrap the `done` callback in a function which either executes at the end of - the current stack (e.g., `nextTick`) or during a subsequent turn of the - event loop (e.g., `setImmediate`, `setTimeout`). - - Parameters - ---------- - predicate: Function - The predicate function which indicates whether to continue invoking a - function. - - fcn: Function - The function to invoke. - - done: Function - Callback to invoke upon completion. - - thisArg: any (optional) - Execution context for the invoked function. - - Examples - -------- - > function predicate( i, clbk ) { clbk( null, i < 5 ); }; - > function fcn( i, next ) { - ... setTimeout( onTimeout, i ); - ... function onTimeout() { - ... next( null, 'boop'+i ); - ... } - ... }; - > function done( error, result ) { - ... if ( error ) { - ... throw error; - ... } - ... console.log( result ); - ... }; - > {{alias}}( predicate, fcn, done ) - boop: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4a543d9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,83 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 whileAsync = require( './index' ); - -const fcn = ( i: number, next: Function ): void => { - if ( i === void 0 ) { - throw new Error( '`i` is missing.' ); - } - next(); -}; - -const predicate = ( i: number, clbk: Function ): void => { - clbk( null, i < 5 ); -}; - -const done = ( error: Error | null ): void => { - if ( error ) { - throw error; - } -}; - - -// TESTS // - -// The function returns void... -{ - whileAsync( predicate, fcn, done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a predicate function... -{ - whileAsync( 2, fcn, done ); // $ExpectError - whileAsync( false, fcn, done ); // $ExpectError - whileAsync( true, fcn, done ); // $ExpectError - whileAsync( 'abc', fcn, done ); // $ExpectError - whileAsync( {}, fcn, done ); // $ExpectError - whileAsync( [], fcn, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function having a supported signature... -{ - whileAsync( predicate, 2, done ); // $ExpectError - whileAsync( predicate, false, done ); // $ExpectError - whileAsync( predicate, true, done ); // $ExpectError - whileAsync( predicate, 'abc', done ); // $ExpectError - whileAsync( predicate, {}, done ); // $ExpectError - whileAsync( predicate, [], done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a done callback argument which is not a function having a supported signature... -{ - whileAsync( predicate, fcn, 2 ); // $ExpectError - whileAsync( predicate, fcn, false ); // $ExpectError - whileAsync( predicate, fcn, true ); // $ExpectError - whileAsync( predicate, fcn, 'abc' ); // $ExpectError - whileAsync( predicate, fcn, {} ); // $ExpectError - whileAsync( predicate, fcn, [] ); // $ExpectError - whileAsync( predicate, fcn, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - whileAsync(); // $ExpectError - whileAsync( predicate ); // $ExpectError - whileAsync( predicate, fcn ); // $ExpectError - whileAsync( predicate, fcn, done, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a6af668..0000000 --- a/examples/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var repeatString = require( '@stdlib/string-repeat' ); -var whileAsync = require( './../lib' ); - -function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } -} - -function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, repeatString( 'beep', i+1 ) ); - } -} - -function done( error, result ) { - if ( error ) { - throw error; - } - console.log( result ); -} - -whileAsync( predicate, fcn, done ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..b4c4a89 --- /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-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,e,i,o){var s,l;if(!r(n))throw new TypeError(t("0im3p",n));if(!r(e))throw new TypeError(t("0im2S",e));if(!r(i))throw new TypeError(t("0im3Z",i));function f(r,t){return r?i(r):t?e.call(o,l,m):(s.length&&s.unshift(null),void i.apply(null,s))}function m(r){var t;if(r)return i(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;uLA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,IAWnB,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,GAhDjBL,EAAO,GAEPJ,EADAK,EAAM,EACUI"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 00bf168..0000000 --- a/lib/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Invoke a function while a test condition is true. -* -* @module @stdlib/utils-async-while -* -* @example -* var whileAsync = require( '@stdlib/utils-async-while' ); -* -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ - -// MODULES // - -var whileAsync = require( './main.js' ); - - -// EXPORTS // - -module.exports = whileAsync; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c03bb93..0000000 --- a/lib/main.js +++ /dev/null @@ -1,128 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Invokes a function while a test condition is true. -* -* @param {Function} predicate - function which indicates whether to continue invoking a function -* @param {Function} fcn - function to invoke -* @param {Callback} done - callback to invoke upon completion -* @param {*} [thisArg] - execution context for the invoked function -* @throws {TypeError} first argument must be a function -* @throws {TypeError} second argument must be a function -* @throws {TypeError} third argument must be a function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -function whileAsync( predicate, fcn, done, thisArg ) { - var args; - var idx; - if ( !isFunction( predicate ) ) { - throw new TypeError( format( '0im3p', predicate ) ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0im2S', fcn ) ); - } - if ( !isFunction( done ) ) { - throw new TypeError( format( '0im3Z', done ) ); - } - args = []; - idx = 0; - predicate( idx, onPredicate ); - - /** - * Callback invoked upon a predicate result. - * - * @private - * @param {(Error|null)} error - error object - * @param {boolean} result - predicate result - * @returns {void} - */ - function onPredicate( error, result ) { - if ( error ) { - return done( error ); - } - if ( result ) { - return fcn.call( thisArg, idx, next ); - } - if ( args.length ) { - args.unshift( null ); // error argument - } - done.apply( null, args ); - } - - /** - * Callback invoked upon completion of a provided function. - * - * @private - * @param {(Error|null)} error - error object - * @param {...*} results - function results - * @returns {void} - */ - function next( error ) { - var i; - if ( error ) { - return done( error ); - } - idx += 1; - - // Cache the most recent results... - if ( arguments.length > 1 ) { - args = new Array( arguments.length-1 ); - for ( i = 1; i < arguments.length; i++ ) { - args[ i-1 ] = arguments[ i ]; - } - } - // Run the test condition: - predicate( idx, onPredicate ); - } -} - - -// EXPORTS // - -module.exports = whileAsync; diff --git a/package.json b/package.json index fcdbeed..411f4ec 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Invoke a function while a test condition is true.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,35 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/bench": "^0.0.x", - "@stdlib/math-base-assert-is-nan": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "@stdlib/string-repeat": "^0.0.x", - "@stdlib/utils-noop": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..70db958 --- /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 78d0688..0000000 --- a/test/test.js +++ /dev/null @@ -1,328 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 whileAsync = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof whileAsync, 'function', 'main export is a function' ); - t.end(); -}); - -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() { - whileAsync( value, noop, 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() { - whileAsync( noop, value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a callback 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() { - whileAsync( noop, noop, value ); - }; - } -}); - -tape( 'while a test condition is true, the function invokes a provided function', function test( t ) { - var indices1 = [ 0, 1, 2, 3, 4, 5 ]; - var indices2 = [ 0, 1, 2, 3, 4 ]; - var j = -1; - var k = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices1[ j ], 'provides expected value' ); - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - k += 1; - t.strictEqual( i, indices2[ k ], 'provides expected value' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'while a test condition is true, the function invokes a provided function (always false)', function test( t ) { - var indices = [ 0 ]; - var j = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices[ j ], 'provides expected value' ); - clbk( null, false ); - } - - function fcn( i, next ) { - t.fail( 'should never be invoked' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx = { - 'count': 0 - }; - - whileAsync( predicate, fcn, done, ctx ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - this.count += 1; // eslint-disable-line no-invalid-this - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( ctx.count, 5, 'updates context' ); - t.end(); - } -}); - -tape( 'the function provides any results to a `done` callback', function test( t ) { - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, 'beep'+i, 'boop'+i, 'woot'+i ); - } - } - - function done( error, str1, str2, str3 ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( str1, 'beep4', 'returns expected value' ); - t.strictEqual( str2, 'boop4', 'returns expected value' ); - t.strictEqual( str3, 'woot4', 'returns expected value' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the predicate function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - if ( i === 1 ) { - return clbk( new Error( 'beep' ) ); - } - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 2, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the provided function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - if ( i === 2 ) { - return next( new Error( 'boop' ) ); - } - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 3, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'the function does not guarantee asynchronous execution', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - k = 1; - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - next(); - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( k, 0, 'releases the zalgo' ); - t.end(); - } -}); From 386b852b2be98c41b1a5c23c5bb7da98ed5550d1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 17 Sep 2022 19:34:42 +0000 Subject: [PATCH 020/143] 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 1dafc2a..c03bb93 100644 --- a/lib/main.js +++ b/lib/main.js @@ -21,7 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -62,13 +62,13 @@ function whileAsync( predicate, fcn, done, thisArg ) { var args; var idx; if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '0im3p', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0im2S', fcn ) ); } if ( !isFunction( done ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', done ) ); + throw new TypeError( format( '0im3Z', done ) ); } args = []; idx = 0; diff --git a/package.json b/package.json index db2fdb6..fcdbeed 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ }, "dependencies": { "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/string-format": "^0.0.x" + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/bench": "^0.0.x", From 943012c020b58d88467af4cf1a16092d4d2fa092 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 17 Sep 2022 19:46:08 +0000 Subject: [PATCH 021/143] Remove files --- index.d.ts | 127 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2821 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 b390f4c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,127 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Callback function. -*/ -type Nullary = () => void; - -/** -* Callback function. -* -* @param error - encountered error or null -*/ -type Unary = ( error: Error | null ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Binary = ( error: Error | null, bool: boolean ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Callback = Nullary | Unary | Binary; - -/** -* Callback invoked upon completion. -*/ -type DoneNullary = () => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -*/ -type DoneUnary = ( error: Error | null ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneBinary = ( error: Error | null, ...args: Array ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneCallback = DoneNullary | DoneUnary | DoneBinary; - -/** -* Checks whether an element in a collection passes a test. -* -* @param i - iteration number (starting from one) -* @param clbk - a callback indicating whether to invoke `fcn` -*/ -type Predicate = ( i: number, clbk: Callback ) => void; - -/** -* Invoked function. -* -* @param i - iteration number (starting from zero) -* @param next - a callback which must be invoked before proceeding to the next iteration -*/ -type Fcn = ( i: number, next: Function ) => void; - -/** -* Invokes a function while a test condition is true. -* -* @param predicate - function which indicates whether to continue invoking a function -* @param fcn - function to invoke -* @param done - callback to invoke upon completion -* @param thisArg - execution context for the invoked function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -declare function whileAsync( predicate: Predicate, fcn: Fcn, done: DoneCallback, thisArg?: any ): void; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = whileAsync; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b4c4a89..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-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,e,i,o){var s,l;if(!r(n))throw new TypeError(t("0im3p",n));if(!r(e))throw new TypeError(t("0im2S",e));if(!r(i))throw new TypeError(t("0im3Z",i));function f(r,t){return r?i(r):t?e.call(o,l,m):(s.length&&s.unshift(null),void i.apply(null,s))}function m(r){var t;if(r)return i(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;uLA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,IAWnB,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,GAhDjBL,EAAO,GAEPJ,EADAK,EAAM,EACUI"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 70db958..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 01424a2c71dae06bcb7249fe86b68809955b6a70 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 17 Sep 2022 19:46:57 +0000 Subject: [PATCH 022/143] Auto-generated commit --- .editorconfig | 181 -- .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 760 ------ .github/workflows/publish.yml | 117 - .github/workflows/test.yml | 92 - .github/workflows/test_bundles.yml | 180 -- .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 178 -- .npmignore | 227 -- .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 ---- README.md | 43 +- benchmark/benchmark.js | 105 - branches.md | 53 - docs/repl.txt | 72 - docs/types/test.ts | 83 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 57 - lib/main.js | 128 - package.json | 56 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 328 --- 36 files changed, 2714 insertions(+), 3853 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 (100%) 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 0f8dec8..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/async/while) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 d8c823e..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/async/while) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -279,7 +272,7 @@ whileAsync( predicate, fcn, done ); ## 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]. @@ -341,13 +334,13 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until +[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until/tree/esm -[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while +[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while/tree/esm -[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until +[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until/tree/esm -[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while +[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index ae9d749..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var whileAsync = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); - -bench( pkg+'::sync_predicate', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 576a70c..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/async/while" -click B href "https://github.com/stdlib-js/utils-async-while/tree/main" -click C href "https://github.com/stdlib-js/utils-async-while/tree/production" -click D href "https://github.com/stdlib-js/utils-async-while/tree/esm" -click E href "https://github.com/stdlib-js/utils-async-while/tree/deno" -click F href "https://github.com/stdlib-js/utils-async-while/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/async/while -[production-url]: https://github.com/stdlib-js/utils-async-while/tree/production -[deno-url]: https://github.com/stdlib-js/utils-async-while/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-async-while/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-async-while/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index d7ca8c9..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,72 +0,0 @@ - -{{alias}}( predicate, fcn, done[, thisArg] ) - Invokes a function while a test condition is true. - - The predicate function is provided two arguments: - - - `i`: iteration number (starting from zero) - - `clbk`: a callback indicating whether to invoke `fcn` - - The `clbk` function accepts two arguments: - - - `error`: error argument - - `bool`: test result - - If the test result is truthy, the function invokes `fcn`; otherwise, the - function invokes the `done` callback. - - The function to invoke is provided two arguments: - - - `i`: iteration number (starting from zero) - - `next`: a callback which must be invoked before proceeding to the next - iteration - - The first argument of the `next` callback is an `error` argument. If `fcn` - calls the `next` callback with a truthy `error` argument, the function - suspends execution and immediately calls the `done` callback for subsequent - `error` handling. - - The `done` callback is invoked with an `error` argument and any arguments - passed to the final `next` callback. - - Execution is *not* guaranteed to be asynchronous. To guarantee asynchrony, - wrap the `done` callback in a function which either executes at the end of - the current stack (e.g., `nextTick`) or during a subsequent turn of the - event loop (e.g., `setImmediate`, `setTimeout`). - - Parameters - ---------- - predicate: Function - The predicate function which indicates whether to continue invoking a - function. - - fcn: Function - The function to invoke. - - done: Function - Callback to invoke upon completion. - - thisArg: any (optional) - Execution context for the invoked function. - - Examples - -------- - > function predicate( i, clbk ) { clbk( null, i < 5 ); }; - > function fcn( i, next ) { - ... setTimeout( onTimeout, i ); - ... function onTimeout() { - ... next( null, 'boop'+i ); - ... } - ... }; - > function done( error, result ) { - ... if ( error ) { - ... throw error; - ... } - ... console.log( result ); - ... }; - > {{alias}}( predicate, fcn, done ) - boop: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4a543d9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,83 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 whileAsync = require( './index' ); - -const fcn = ( i: number, next: Function ): void => { - if ( i === void 0 ) { - throw new Error( '`i` is missing.' ); - } - next(); -}; - -const predicate = ( i: number, clbk: Function ): void => { - clbk( null, i < 5 ); -}; - -const done = ( error: Error | null ): void => { - if ( error ) { - throw error; - } -}; - - -// TESTS // - -// The function returns void... -{ - whileAsync( predicate, fcn, done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a predicate function... -{ - whileAsync( 2, fcn, done ); // $ExpectError - whileAsync( false, fcn, done ); // $ExpectError - whileAsync( true, fcn, done ); // $ExpectError - whileAsync( 'abc', fcn, done ); // $ExpectError - whileAsync( {}, fcn, done ); // $ExpectError - whileAsync( [], fcn, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function having a supported signature... -{ - whileAsync( predicate, 2, done ); // $ExpectError - whileAsync( predicate, false, done ); // $ExpectError - whileAsync( predicate, true, done ); // $ExpectError - whileAsync( predicate, 'abc', done ); // $ExpectError - whileAsync( predicate, {}, done ); // $ExpectError - whileAsync( predicate, [], done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a done callback argument which is not a function having a supported signature... -{ - whileAsync( predicate, fcn, 2 ); // $ExpectError - whileAsync( predicate, fcn, false ); // $ExpectError - whileAsync( predicate, fcn, true ); // $ExpectError - whileAsync( predicate, fcn, 'abc' ); // $ExpectError - whileAsync( predicate, fcn, {} ); // $ExpectError - whileAsync( predicate, fcn, [] ); // $ExpectError - whileAsync( predicate, fcn, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - whileAsync(); // $ExpectError - whileAsync( predicate ); // $ExpectError - whileAsync( predicate, fcn ); // $ExpectError - whileAsync( predicate, fcn, done, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a6af668..0000000 --- a/examples/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var repeatString = require( '@stdlib/string-repeat' ); -var whileAsync = require( './../lib' ); - -function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } -} - -function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, repeatString( 'beep', i+1 ) ); - } -} - -function done( error, result ) { - if ( error ) { - throw error; - } - console.log( result ); -} - -whileAsync( predicate, fcn, done ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..b4c4a89 --- /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-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,e,i,o){var s,l;if(!r(n))throw new TypeError(t("0im3p",n));if(!r(e))throw new TypeError(t("0im2S",e));if(!r(i))throw new TypeError(t("0im3Z",i));function f(r,t){return r?i(r):t?e.call(o,l,m):(s.length&&s.unshift(null),void i.apply(null,s))}function m(r){var t;if(r)return i(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;uLA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,IAWnB,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,GAhDjBL,EAAO,GAEPJ,EADAK,EAAM,EACUI"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a13bd4..0000000 --- a/lib/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Invoke a function while a test condition is true. -* -* @module @stdlib/utils-async-while -* -* @example -* var whileAsync = require( '@stdlib/utils-async-while' ); -* -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c03bb93..0000000 --- a/lib/main.js +++ /dev/null @@ -1,128 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Invokes a function while a test condition is true. -* -* @param {Function} predicate - function which indicates whether to continue invoking a function -* @param {Function} fcn - function to invoke -* @param {Callback} done - callback to invoke upon completion -* @param {*} [thisArg] - execution context for the invoked function -* @throws {TypeError} first argument must be a function -* @throws {TypeError} second argument must be a function -* @throws {TypeError} third argument must be a function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -function whileAsync( predicate, fcn, done, thisArg ) { - var args; - var idx; - if ( !isFunction( predicate ) ) { - throw new TypeError( format( '0im3p', predicate ) ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0im2S', fcn ) ); - } - if ( !isFunction( done ) ) { - throw new TypeError( format( '0im3Z', done ) ); - } - args = []; - idx = 0; - predicate( idx, onPredicate ); - - /** - * Callback invoked upon a predicate result. - * - * @private - * @param {(Error|null)} error - error object - * @param {boolean} result - predicate result - * @returns {void} - */ - function onPredicate( error, result ) { - if ( error ) { - return done( error ); - } - if ( result ) { - return fcn.call( thisArg, idx, next ); - } - if ( args.length ) { - args.unshift( null ); // error argument - } - done.apply( null, args ); - } - - /** - * Callback invoked upon completion of a provided function. - * - * @private - * @param {(Error|null)} error - error object - * @param {...*} results - function results - * @returns {void} - */ - function next( error ) { - var i; - if ( error ) { - return done( error ); - } - idx += 1; - - // Cache the most recent results... - if ( arguments.length > 1 ) { - args = new Array( arguments.length-1 ); - for ( i = 1; i < arguments.length; i++ ) { - args[ i-1 ] = arguments[ i ]; - } - } - // Run the test condition: - predicate( idx, onPredicate ); - } -} - - -// EXPORTS // - -module.exports = whileAsync; diff --git a/package.json b/package.json index fcdbeed..411f4ec 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Invoke a function while a test condition is true.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,35 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/bench": "^0.0.x", - "@stdlib/math-base-assert-is-nan": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "@stdlib/string-repeat": "^0.0.x", - "@stdlib/utils-noop": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..ddf459a --- /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 78d0688..0000000 --- a/test/test.js +++ /dev/null @@ -1,328 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 whileAsync = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof whileAsync, 'function', 'main export is a function' ); - t.end(); -}); - -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() { - whileAsync( value, noop, 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() { - whileAsync( noop, value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a callback 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() { - whileAsync( noop, noop, value ); - }; - } -}); - -tape( 'while a test condition is true, the function invokes a provided function', function test( t ) { - var indices1 = [ 0, 1, 2, 3, 4, 5 ]; - var indices2 = [ 0, 1, 2, 3, 4 ]; - var j = -1; - var k = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices1[ j ], 'provides expected value' ); - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - k += 1; - t.strictEqual( i, indices2[ k ], 'provides expected value' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'while a test condition is true, the function invokes a provided function (always false)', function test( t ) { - var indices = [ 0 ]; - var j = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices[ j ], 'provides expected value' ); - clbk( null, false ); - } - - function fcn( i, next ) { - t.fail( 'should never be invoked' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx = { - 'count': 0 - }; - - whileAsync( predicate, fcn, done, ctx ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - this.count += 1; // eslint-disable-line no-invalid-this - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( ctx.count, 5, 'updates context' ); - t.end(); - } -}); - -tape( 'the function provides any results to a `done` callback', function test( t ) { - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, 'beep'+i, 'boop'+i, 'woot'+i ); - } - } - - function done( error, str1, str2, str3 ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( str1, 'beep4', 'returns expected value' ); - t.strictEqual( str2, 'boop4', 'returns expected value' ); - t.strictEqual( str3, 'woot4', 'returns expected value' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the predicate function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - if ( i === 1 ) { - return clbk( new Error( 'beep' ) ); - } - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 2, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the provided function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - if ( i === 2 ) { - return next( new Error( 'boop' ) ); - } - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 3, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'the function does not guarantee asynchronous execution', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - k = 1; - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - next(); - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( k, 0, 'releases the zalgo' ); - t.end(); - } -}); From b6715bfc4314a3d6dca30cc4641937b7e720efc0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 04:44:45 +0000 Subject: [PATCH 023/143] 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 1dafc2a..c03bb93 100644 --- a/lib/main.js +++ b/lib/main.js @@ -21,7 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -62,13 +62,13 @@ function whileAsync( predicate, fcn, done, thisArg ) { var args; var idx; if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '0im3p', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0im2S', fcn ) ); } if ( !isFunction( done ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', done ) ); + throw new TypeError( format( '0im3Z', done ) ); } args = []; idx = 0; diff --git a/package.json b/package.json index db2fdb6..fcdbeed 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ }, "dependencies": { "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/string-format": "^0.0.x" + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/bench": "^0.0.x", From 2692c7452a30e9dbb368d658f13e9de180dd88aa Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 19:37:54 +0000 Subject: [PATCH 024/143] Remove files --- index.d.ts | 127 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2821 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 b390f4c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,127 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Callback function. -*/ -type Nullary = () => void; - -/** -* Callback function. -* -* @param error - encountered error or null -*/ -type Unary = ( error: Error | null ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Binary = ( error: Error | null, bool: boolean ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Callback = Nullary | Unary | Binary; - -/** -* Callback invoked upon completion. -*/ -type DoneNullary = () => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -*/ -type DoneUnary = ( error: Error | null ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneBinary = ( error: Error | null, ...args: Array ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneCallback = DoneNullary | DoneUnary | DoneBinary; - -/** -* Checks whether an element in a collection passes a test. -* -* @param i - iteration number (starting from one) -* @param clbk - a callback indicating whether to invoke `fcn` -*/ -type Predicate = ( i: number, clbk: Callback ) => void; - -/** -* Invoked function. -* -* @param i - iteration number (starting from zero) -* @param next - a callback which must be invoked before proceeding to the next iteration -*/ -type Fcn = ( i: number, next: Function ) => void; - -/** -* Invokes a function while a test condition is true. -* -* @param predicate - function which indicates whether to continue invoking a function -* @param fcn - function to invoke -* @param done - callback to invoke upon completion -* @param thisArg - execution context for the invoked function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -declare function whileAsync( predicate: Predicate, fcn: Fcn, done: DoneCallback, thisArg?: any ): void; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = whileAsync; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b4c4a89..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-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,e,i,o){var s,l;if(!r(n))throw new TypeError(t("0im3p",n));if(!r(e))throw new TypeError(t("0im2S",e));if(!r(i))throw new TypeError(t("0im3Z",i));function f(r,t){return r?i(r):t?e.call(o,l,m):(s.length&&s.unshift(null),void i.apply(null,s))}function m(r){var t;if(r)return i(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;uLA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,IAWnB,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,GAhDjBL,EAAO,GAEPJ,EADAK,EAAM,EACUI"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index ddf459a..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From db8ecaaa08933c1284d06cd5e01e6fcc4dcb542c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 19:38:48 +0000 Subject: [PATCH 025/143] 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 | 105 - branches.md | 53 - docs/repl.txt | 72 - docs/types/test.ts | 83 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 57 - lib/main.js | 128 - package.json | 56 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 328 --- 37 files changed, 2714 insertions(+), 3854 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 (100%) 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 6c1cfbc..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-10-01T01:05:42.108Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 0f8dec8..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/async/while) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 d8c823e..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/async/while) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -279,7 +272,7 @@ whileAsync( predicate, fcn, done ); ## 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]. @@ -341,13 +334,13 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until +[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until/tree/esm -[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while +[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while/tree/esm -[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until +[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until/tree/esm -[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while +[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index ae9d749..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var whileAsync = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); - -bench( pkg+'::sync_predicate', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 576a70c..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/async/while" -click B href "https://github.com/stdlib-js/utils-async-while/tree/main" -click C href "https://github.com/stdlib-js/utils-async-while/tree/production" -click D href "https://github.com/stdlib-js/utils-async-while/tree/esm" -click E href "https://github.com/stdlib-js/utils-async-while/tree/deno" -click F href "https://github.com/stdlib-js/utils-async-while/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/async/while -[production-url]: https://github.com/stdlib-js/utils-async-while/tree/production -[deno-url]: https://github.com/stdlib-js/utils-async-while/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-async-while/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-async-while/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index d7ca8c9..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,72 +0,0 @@ - -{{alias}}( predicate, fcn, done[, thisArg] ) - Invokes a function while a test condition is true. - - The predicate function is provided two arguments: - - - `i`: iteration number (starting from zero) - - `clbk`: a callback indicating whether to invoke `fcn` - - The `clbk` function accepts two arguments: - - - `error`: error argument - - `bool`: test result - - If the test result is truthy, the function invokes `fcn`; otherwise, the - function invokes the `done` callback. - - The function to invoke is provided two arguments: - - - `i`: iteration number (starting from zero) - - `next`: a callback which must be invoked before proceeding to the next - iteration - - The first argument of the `next` callback is an `error` argument. If `fcn` - calls the `next` callback with a truthy `error` argument, the function - suspends execution and immediately calls the `done` callback for subsequent - `error` handling. - - The `done` callback is invoked with an `error` argument and any arguments - passed to the final `next` callback. - - Execution is *not* guaranteed to be asynchronous. To guarantee asynchrony, - wrap the `done` callback in a function which either executes at the end of - the current stack (e.g., `nextTick`) or during a subsequent turn of the - event loop (e.g., `setImmediate`, `setTimeout`). - - Parameters - ---------- - predicate: Function - The predicate function which indicates whether to continue invoking a - function. - - fcn: Function - The function to invoke. - - done: Function - Callback to invoke upon completion. - - thisArg: any (optional) - Execution context for the invoked function. - - Examples - -------- - > function predicate( i, clbk ) { clbk( null, i < 5 ); }; - > function fcn( i, next ) { - ... setTimeout( onTimeout, i ); - ... function onTimeout() { - ... next( null, 'boop'+i ); - ... } - ... }; - > function done( error, result ) { - ... if ( error ) { - ... throw error; - ... } - ... console.log( result ); - ... }; - > {{alias}}( predicate, fcn, done ) - boop: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4a543d9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,83 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 whileAsync = require( './index' ); - -const fcn = ( i: number, next: Function ): void => { - if ( i === void 0 ) { - throw new Error( '`i` is missing.' ); - } - next(); -}; - -const predicate = ( i: number, clbk: Function ): void => { - clbk( null, i < 5 ); -}; - -const done = ( error: Error | null ): void => { - if ( error ) { - throw error; - } -}; - - -// TESTS // - -// The function returns void... -{ - whileAsync( predicate, fcn, done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a predicate function... -{ - whileAsync( 2, fcn, done ); // $ExpectError - whileAsync( false, fcn, done ); // $ExpectError - whileAsync( true, fcn, done ); // $ExpectError - whileAsync( 'abc', fcn, done ); // $ExpectError - whileAsync( {}, fcn, done ); // $ExpectError - whileAsync( [], fcn, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function having a supported signature... -{ - whileAsync( predicate, 2, done ); // $ExpectError - whileAsync( predicate, false, done ); // $ExpectError - whileAsync( predicate, true, done ); // $ExpectError - whileAsync( predicate, 'abc', done ); // $ExpectError - whileAsync( predicate, {}, done ); // $ExpectError - whileAsync( predicate, [], done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a done callback argument which is not a function having a supported signature... -{ - whileAsync( predicate, fcn, 2 ); // $ExpectError - whileAsync( predicate, fcn, false ); // $ExpectError - whileAsync( predicate, fcn, true ); // $ExpectError - whileAsync( predicate, fcn, 'abc' ); // $ExpectError - whileAsync( predicate, fcn, {} ); // $ExpectError - whileAsync( predicate, fcn, [] ); // $ExpectError - whileAsync( predicate, fcn, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - whileAsync(); // $ExpectError - whileAsync( predicate ); // $ExpectError - whileAsync( predicate, fcn ); // $ExpectError - whileAsync( predicate, fcn, done, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a6af668..0000000 --- a/examples/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var repeatString = require( '@stdlib/string-repeat' ); -var whileAsync = require( './../lib' ); - -function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } -} - -function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, repeatString( 'beep', i+1 ) ); - } -} - -function done( error, result ) { - if ( error ) { - throw error; - } - console.log( result ); -} - -whileAsync( predicate, fcn, done ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..b4c4a89 --- /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-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,e,i,o){var s,l;if(!r(n))throw new TypeError(t("0im3p",n));if(!r(e))throw new TypeError(t("0im2S",e));if(!r(i))throw new TypeError(t("0im3Z",i));function f(r,t){return r?i(r):t?e.call(o,l,m):(s.length&&s.unshift(null),void i.apply(null,s))}function m(r){var t;if(r)return i(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;uLA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,IAWnB,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,GAhDjBL,EAAO,GAEPJ,EADAK,EAAM,EACUI"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a13bd4..0000000 --- a/lib/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Invoke a function while a test condition is true. -* -* @module @stdlib/utils-async-while -* -* @example -* var whileAsync = require( '@stdlib/utils-async-while' ); -* -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c03bb93..0000000 --- a/lib/main.js +++ /dev/null @@ -1,128 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Invokes a function while a test condition is true. -* -* @param {Function} predicate - function which indicates whether to continue invoking a function -* @param {Function} fcn - function to invoke -* @param {Callback} done - callback to invoke upon completion -* @param {*} [thisArg] - execution context for the invoked function -* @throws {TypeError} first argument must be a function -* @throws {TypeError} second argument must be a function -* @throws {TypeError} third argument must be a function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -function whileAsync( predicate, fcn, done, thisArg ) { - var args; - var idx; - if ( !isFunction( predicate ) ) { - throw new TypeError( format( '0im3p', predicate ) ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0im2S', fcn ) ); - } - if ( !isFunction( done ) ) { - throw new TypeError( format( '0im3Z', done ) ); - } - args = []; - idx = 0; - predicate( idx, onPredicate ); - - /** - * Callback invoked upon a predicate result. - * - * @private - * @param {(Error|null)} error - error object - * @param {boolean} result - predicate result - * @returns {void} - */ - function onPredicate( error, result ) { - if ( error ) { - return done( error ); - } - if ( result ) { - return fcn.call( thisArg, idx, next ); - } - if ( args.length ) { - args.unshift( null ); // error argument - } - done.apply( null, args ); - } - - /** - * Callback invoked upon completion of a provided function. - * - * @private - * @param {(Error|null)} error - error object - * @param {...*} results - function results - * @returns {void} - */ - function next( error ) { - var i; - if ( error ) { - return done( error ); - } - idx += 1; - - // Cache the most recent results... - if ( arguments.length > 1 ) { - args = new Array( arguments.length-1 ); - for ( i = 1; i < arguments.length; i++ ) { - args[ i-1 ] = arguments[ i ]; - } - } - // Run the test condition: - predicate( idx, onPredicate ); - } -} - - -// EXPORTS // - -module.exports = whileAsync; diff --git a/package.json b/package.json index fcdbeed..411f4ec 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Invoke a function while a test condition is true.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,35 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/bench": "^0.0.x", - "@stdlib/math-base-assert-is-nan": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "@stdlib/string-repeat": "^0.0.x", - "@stdlib/utils-noop": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..c8dad59 --- /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 78d0688..0000000 --- a/test/test.js +++ /dev/null @@ -1,328 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 whileAsync = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof whileAsync, 'function', 'main export is a function' ); - t.end(); -}); - -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() { - whileAsync( value, noop, 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() { - whileAsync( noop, value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a callback 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() { - whileAsync( noop, noop, value ); - }; - } -}); - -tape( 'while a test condition is true, the function invokes a provided function', function test( t ) { - var indices1 = [ 0, 1, 2, 3, 4, 5 ]; - var indices2 = [ 0, 1, 2, 3, 4 ]; - var j = -1; - var k = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices1[ j ], 'provides expected value' ); - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - k += 1; - t.strictEqual( i, indices2[ k ], 'provides expected value' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'while a test condition is true, the function invokes a provided function (always false)', function test( t ) { - var indices = [ 0 ]; - var j = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices[ j ], 'provides expected value' ); - clbk( null, false ); - } - - function fcn( i, next ) { - t.fail( 'should never be invoked' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx = { - 'count': 0 - }; - - whileAsync( predicate, fcn, done, ctx ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - this.count += 1; // eslint-disable-line no-invalid-this - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( ctx.count, 5, 'updates context' ); - t.end(); - } -}); - -tape( 'the function provides any results to a `done` callback', function test( t ) { - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, 'beep'+i, 'boop'+i, 'woot'+i ); - } - } - - function done( error, str1, str2, str3 ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( str1, 'beep4', 'returns expected value' ); - t.strictEqual( str2, 'boop4', 'returns expected value' ); - t.strictEqual( str3, 'woot4', 'returns expected value' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the predicate function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - if ( i === 1 ) { - return clbk( new Error( 'beep' ) ); - } - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 2, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the provided function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - if ( i === 2 ) { - return next( new Error( 'boop' ) ); - } - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 3, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'the function does not guarantee asynchronous execution', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - k = 1; - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - next(); - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( k, 0, 'releases the zalgo' ); - t.end(); - } -}); From ace608d87a0cf3355224705b5ed33a4f12686b76 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 00:53:57 +0000 Subject: [PATCH 026/143] 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 1dafc2a..c03bb93 100644 --- a/lib/main.js +++ b/lib/main.js @@ -21,7 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -62,13 +62,13 @@ function whileAsync( predicate, fcn, done, thisArg ) { var args; var idx; if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '0im3p', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0im2S', fcn ) ); } if ( !isFunction( done ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', done ) ); + throw new TypeError( format( '0im3Z', done ) ); } args = []; idx = 0; diff --git a/package.json b/package.json index db2fdb6..fcdbeed 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ }, "dependencies": { "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/string-format": "^0.0.x" + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/bench": "^0.0.x", From f2f896d378c7edaa3c68e6258c6cae3c57404ca7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 13:48:59 +0000 Subject: [PATCH 027/143] Remove files --- index.d.ts | 127 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2821 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 b390f4c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,127 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Callback function. -*/ -type Nullary = () => void; - -/** -* Callback function. -* -* @param error - encountered error or null -*/ -type Unary = ( error: Error | null ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Binary = ( error: Error | null, bool: boolean ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Callback = Nullary | Unary | Binary; - -/** -* Callback invoked upon completion. -*/ -type DoneNullary = () => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -*/ -type DoneUnary = ( error: Error | null ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneBinary = ( error: Error | null, ...args: Array ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneCallback = DoneNullary | DoneUnary | DoneBinary; - -/** -* Checks whether an element in a collection passes a test. -* -* @param i - iteration number (starting from one) -* @param clbk - a callback indicating whether to invoke `fcn` -*/ -type Predicate = ( i: number, clbk: Callback ) => void; - -/** -* Invoked function. -* -* @param i - iteration number (starting from zero) -* @param next - a callback which must be invoked before proceeding to the next iteration -*/ -type Fcn = ( i: number, next: Function ) => void; - -/** -* Invokes a function while a test condition is true. -* -* @param predicate - function which indicates whether to continue invoking a function -* @param fcn - function to invoke -* @param done - callback to invoke upon completion -* @param thisArg - execution context for the invoked function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -declare function whileAsync( predicate: Predicate, fcn: Fcn, done: DoneCallback, thisArg?: any ): void; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = whileAsync; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b4c4a89..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-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,e,i,o){var s,l;if(!r(n))throw new TypeError(t("0im3p",n));if(!r(e))throw new TypeError(t("0im2S",e));if(!r(i))throw new TypeError(t("0im3Z",i));function f(r,t){return r?i(r):t?e.call(o,l,m):(s.length&&s.unshift(null),void i.apply(null,s))}function m(r){var t;if(r)return i(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;uLA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,IAWnB,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,GAhDjBL,EAAO,GAEPJ,EADAK,EAAM,EACUI"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index c8dad59..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From e4fb92adb9f4cbe5ef3e30c7e37d8cc0f57ae64a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 13:49:50 +0000 Subject: [PATCH 028/143] 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 | 105 - branches.md | 53 - docs/repl.txt | 72 - docs/types/test.ts | 83 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 57 - lib/main.js | 128 - package.json | 56 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 328 -- 37 files changed, 4069 insertions(+), 3854 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 (100%) 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 7d3efed..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-11-01T00:52:26.003Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 0f8dec8..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/async/while) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 d8c823e..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/async/while) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 51569a6..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: '8 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@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 + + ```
@@ -279,7 +272,7 @@ whileAsync( predicate, fcn, done ); ## 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]. @@ -341,13 +334,13 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until +[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until/tree/esm -[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while +[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while/tree/esm -[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until +[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until/tree/esm -[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while +[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index ae9d749..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var whileAsync = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); - -bench( pkg+'::sync_predicate', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 576a70c..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/async/while" -click B href "https://github.com/stdlib-js/utils-async-while/tree/main" -click C href "https://github.com/stdlib-js/utils-async-while/tree/production" -click D href "https://github.com/stdlib-js/utils-async-while/tree/esm" -click E href "https://github.com/stdlib-js/utils-async-while/tree/deno" -click F href "https://github.com/stdlib-js/utils-async-while/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/async/while -[production-url]: https://github.com/stdlib-js/utils-async-while/tree/production -[deno-url]: https://github.com/stdlib-js/utils-async-while/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-async-while/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-async-while/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index d7ca8c9..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,72 +0,0 @@ - -{{alias}}( predicate, fcn, done[, thisArg] ) - Invokes a function while a test condition is true. - - The predicate function is provided two arguments: - - - `i`: iteration number (starting from zero) - - `clbk`: a callback indicating whether to invoke `fcn` - - The `clbk` function accepts two arguments: - - - `error`: error argument - - `bool`: test result - - If the test result is truthy, the function invokes `fcn`; otherwise, the - function invokes the `done` callback. - - The function to invoke is provided two arguments: - - - `i`: iteration number (starting from zero) - - `next`: a callback which must be invoked before proceeding to the next - iteration - - The first argument of the `next` callback is an `error` argument. If `fcn` - calls the `next` callback with a truthy `error` argument, the function - suspends execution and immediately calls the `done` callback for subsequent - `error` handling. - - The `done` callback is invoked with an `error` argument and any arguments - passed to the final `next` callback. - - Execution is *not* guaranteed to be asynchronous. To guarantee asynchrony, - wrap the `done` callback in a function which either executes at the end of - the current stack (e.g., `nextTick`) or during a subsequent turn of the - event loop (e.g., `setImmediate`, `setTimeout`). - - Parameters - ---------- - predicate: Function - The predicate function which indicates whether to continue invoking a - function. - - fcn: Function - The function to invoke. - - done: Function - Callback to invoke upon completion. - - thisArg: any (optional) - Execution context for the invoked function. - - Examples - -------- - > function predicate( i, clbk ) { clbk( null, i < 5 ); }; - > function fcn( i, next ) { - ... setTimeout( onTimeout, i ); - ... function onTimeout() { - ... next( null, 'boop'+i ); - ... } - ... }; - > function done( error, result ) { - ... if ( error ) { - ... throw error; - ... } - ... console.log( result ); - ... }; - > {{alias}}( predicate, fcn, done ) - boop: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4a543d9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,83 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 whileAsync = require( './index' ); - -const fcn = ( i: number, next: Function ): void => { - if ( i === void 0 ) { - throw new Error( '`i` is missing.' ); - } - next(); -}; - -const predicate = ( i: number, clbk: Function ): void => { - clbk( null, i < 5 ); -}; - -const done = ( error: Error | null ): void => { - if ( error ) { - throw error; - } -}; - - -// TESTS // - -// The function returns void... -{ - whileAsync( predicate, fcn, done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a predicate function... -{ - whileAsync( 2, fcn, done ); // $ExpectError - whileAsync( false, fcn, done ); // $ExpectError - whileAsync( true, fcn, done ); // $ExpectError - whileAsync( 'abc', fcn, done ); // $ExpectError - whileAsync( {}, fcn, done ); // $ExpectError - whileAsync( [], fcn, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function having a supported signature... -{ - whileAsync( predicate, 2, done ); // $ExpectError - whileAsync( predicate, false, done ); // $ExpectError - whileAsync( predicate, true, done ); // $ExpectError - whileAsync( predicate, 'abc', done ); // $ExpectError - whileAsync( predicate, {}, done ); // $ExpectError - whileAsync( predicate, [], done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a done callback argument which is not a function having a supported signature... -{ - whileAsync( predicate, fcn, 2 ); // $ExpectError - whileAsync( predicate, fcn, false ); // $ExpectError - whileAsync( predicate, fcn, true ); // $ExpectError - whileAsync( predicate, fcn, 'abc' ); // $ExpectError - whileAsync( predicate, fcn, {} ); // $ExpectError - whileAsync( predicate, fcn, [] ); // $ExpectError - whileAsync( predicate, fcn, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - whileAsync(); // $ExpectError - whileAsync( predicate ); // $ExpectError - whileAsync( predicate, fcn ); // $ExpectError - whileAsync( predicate, fcn, done, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a6af668..0000000 --- a/examples/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var repeatString = require( '@stdlib/string-repeat' ); -var whileAsync = require( './../lib' ); - -function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } -} - -function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, repeatString( 'beep', i+1 ) ); - } -} - -function done( error, result ) { - if ( error ) { - throw error; - } - console.log( result ); -} - -whileAsync( predicate, fcn, done ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..b4c4a89 --- /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-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,e,i,o){var s,l;if(!r(n))throw new TypeError(t("0im3p",n));if(!r(e))throw new TypeError(t("0im2S",e));if(!r(i))throw new TypeError(t("0im3Z",i));function f(r,t){return r?i(r):t?e.call(o,l,m):(s.length&&s.unshift(null),void i.apply(null,s))}function m(r){var t;if(r)return i(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;uLA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a13bd4..0000000 --- a/lib/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Invoke a function while a test condition is true. -* -* @module @stdlib/utils-async-while -* -* @example -* var whileAsync = require( '@stdlib/utils-async-while' ); -* -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c03bb93..0000000 --- a/lib/main.js +++ /dev/null @@ -1,128 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Invokes a function while a test condition is true. -* -* @param {Function} predicate - function which indicates whether to continue invoking a function -* @param {Function} fcn - function to invoke -* @param {Callback} done - callback to invoke upon completion -* @param {*} [thisArg] - execution context for the invoked function -* @throws {TypeError} first argument must be a function -* @throws {TypeError} second argument must be a function -* @throws {TypeError} third argument must be a function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -function whileAsync( predicate, fcn, done, thisArg ) { - var args; - var idx; - if ( !isFunction( predicate ) ) { - throw new TypeError( format( '0im3p', predicate ) ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0im2S', fcn ) ); - } - if ( !isFunction( done ) ) { - throw new TypeError( format( '0im3Z', done ) ); - } - args = []; - idx = 0; - predicate( idx, onPredicate ); - - /** - * Callback invoked upon a predicate result. - * - * @private - * @param {(Error|null)} error - error object - * @param {boolean} result - predicate result - * @returns {void} - */ - function onPredicate( error, result ) { - if ( error ) { - return done( error ); - } - if ( result ) { - return fcn.call( thisArg, idx, next ); - } - if ( args.length ) { - args.unshift( null ); // error argument - } - done.apply( null, args ); - } - - /** - * Callback invoked upon completion of a provided function. - * - * @private - * @param {(Error|null)} error - error object - * @param {...*} results - function results - * @returns {void} - */ - function next( error ) { - var i; - if ( error ) { - return done( error ); - } - idx += 1; - - // Cache the most recent results... - if ( arguments.length > 1 ) { - args = new Array( arguments.length-1 ); - for ( i = 1; i < arguments.length; i++ ) { - args[ i-1 ] = arguments[ i ]; - } - } - // Run the test condition: - predicate( idx, onPredicate ); - } -} - - -// EXPORTS // - -module.exports = whileAsync; diff --git a/package.json b/package.json index fcdbeed..411f4ec 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Invoke a function while a test condition is true.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,35 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/bench": "^0.0.x", - "@stdlib/math-base-assert-is-nan": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "@stdlib/string-repeat": "^0.0.x", - "@stdlib/utils-noop": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..ecddb4d --- /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 78d0688..0000000 --- a/test/test.js +++ /dev/null @@ -1,328 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 whileAsync = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof whileAsync, 'function', 'main export is a function' ); - t.end(); -}); - -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() { - whileAsync( value, noop, 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() { - whileAsync( noop, value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a callback 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() { - whileAsync( noop, noop, value ); - }; - } -}); - -tape( 'while a test condition is true, the function invokes a provided function', function test( t ) { - var indices1 = [ 0, 1, 2, 3, 4, 5 ]; - var indices2 = [ 0, 1, 2, 3, 4 ]; - var j = -1; - var k = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices1[ j ], 'provides expected value' ); - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - k += 1; - t.strictEqual( i, indices2[ k ], 'provides expected value' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'while a test condition is true, the function invokes a provided function (always false)', function test( t ) { - var indices = [ 0 ]; - var j = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices[ j ], 'provides expected value' ); - clbk( null, false ); - } - - function fcn( i, next ) { - t.fail( 'should never be invoked' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx = { - 'count': 0 - }; - - whileAsync( predicate, fcn, done, ctx ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - this.count += 1; // eslint-disable-line no-invalid-this - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( ctx.count, 5, 'updates context' ); - t.end(); - } -}); - -tape( 'the function provides any results to a `done` callback', function test( t ) { - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, 'beep'+i, 'boop'+i, 'woot'+i ); - } - } - - function done( error, str1, str2, str3 ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( str1, 'beep4', 'returns expected value' ); - t.strictEqual( str2, 'boop4', 'returns expected value' ); - t.strictEqual( str3, 'woot4', 'returns expected value' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the predicate function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - if ( i === 1 ) { - return clbk( new Error( 'beep' ) ); - } - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 2, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the provided function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - if ( i === 2 ) { - return next( new Error( 'boop' ) ); - } - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 3, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'the function does not guarantee asynchronous execution', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - k = 1; - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - next(); - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( k, 0, 'releases the zalgo' ); - t.end(); - } -}); From 983f70915ff7d425fc2dc8596483f709dd41eef0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 3 Nov 2022 23:31:46 +0000 Subject: [PATCH 029/143] 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 1dafc2a..c03bb93 100644 --- a/lib/main.js +++ b/lib/main.js @@ -21,7 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -62,13 +62,13 @@ function whileAsync( predicate, fcn, done, thisArg ) { var args; var idx; if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '0im3p', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0im2S', fcn ) ); } if ( !isFunction( done ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', done ) ); + throw new TypeError( format( '0im3Z', done ) ); } args = []; idx = 0; diff --git a/package.json b/package.json index db2fdb6..fcdbeed 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ }, "dependencies": { "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/string-format": "^0.0.x" + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/bench": "^0.0.x", From 3d82095f3a24df2da6fc44f3a27759b268a1bb33 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 06:35:52 +0000 Subject: [PATCH 030/143] Remove files --- index.d.ts | 127 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4176 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 b390f4c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,127 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Callback function. -*/ -type Nullary = () => void; - -/** -* Callback function. -* -* @param error - encountered error or null -*/ -type Unary = ( error: Error | null ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Binary = ( error: Error | null, bool: boolean ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Callback = Nullary | Unary | Binary; - -/** -* Callback invoked upon completion. -*/ -type DoneNullary = () => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -*/ -type DoneUnary = ( error: Error | null ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneBinary = ( error: Error | null, ...args: Array ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneCallback = DoneNullary | DoneUnary | DoneBinary; - -/** -* Checks whether an element in a collection passes a test. -* -* @param i - iteration number (starting from one) -* @param clbk - a callback indicating whether to invoke `fcn` -*/ -type Predicate = ( i: number, clbk: Callback ) => void; - -/** -* Invoked function. -* -* @param i - iteration number (starting from zero) -* @param next - a callback which must be invoked before proceeding to the next iteration -*/ -type Fcn = ( i: number, next: Function ) => void; - -/** -* Invokes a function while a test condition is true. -* -* @param predicate - function which indicates whether to continue invoking a function -* @param fcn - function to invoke -* @param done - callback to invoke upon completion -* @param thisArg - execution context for the invoked function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -declare function whileAsync( predicate: Predicate, fcn: Fcn, done: DoneCallback, thisArg?: any ): void; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = whileAsync; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b4c4a89..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-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,e,i,o){var s,l;if(!r(n))throw new TypeError(t("0im3p",n));if(!r(e))throw new TypeError(t("0im2S",e));if(!r(i))throw new TypeError(t("0im3Z",i));function f(r,t){return r?i(r):t?e.call(o,l,m):(s.length&&s.unshift(null),void i.apply(null,s))}function m(r){var t;if(r)return i(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;uLA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index ecddb4d..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 26cc5ee53b03765f30be9b86f8a69519bef1307f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 06:36:39 +0000 Subject: [PATCH 031/143] 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 | 105 - branches.md | 53 - docs/repl.txt | 72 - docs/types/test.ts | 83 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 57 - lib/main.js | 128 - package.json | 56 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 328 -- 37 files changed, 4069 insertions(+), 3875 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 (100%) 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 70afc65..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-11-03T20:59:47.201Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 0f8dec8..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/async/while) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 d8c823e..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/async/while) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 51569a6..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: '8 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@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 + + ```
@@ -279,7 +272,7 @@ whileAsync( predicate, fcn, done ); ## 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]. @@ -341,13 +334,13 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until +[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until/tree/esm -[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while +[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while/tree/esm -[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until +[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until/tree/esm -[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while +[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index ae9d749..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var whileAsync = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); - -bench( pkg+'::sync_predicate', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 576a70c..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/async/while" -click B href "https://github.com/stdlib-js/utils-async-while/tree/main" -click C href "https://github.com/stdlib-js/utils-async-while/tree/production" -click D href "https://github.com/stdlib-js/utils-async-while/tree/esm" -click E href "https://github.com/stdlib-js/utils-async-while/tree/deno" -click F href "https://github.com/stdlib-js/utils-async-while/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/async/while -[production-url]: https://github.com/stdlib-js/utils-async-while/tree/production -[deno-url]: https://github.com/stdlib-js/utils-async-while/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-async-while/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-async-while/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index d7ca8c9..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,72 +0,0 @@ - -{{alias}}( predicate, fcn, done[, thisArg] ) - Invokes a function while a test condition is true. - - The predicate function is provided two arguments: - - - `i`: iteration number (starting from zero) - - `clbk`: a callback indicating whether to invoke `fcn` - - The `clbk` function accepts two arguments: - - - `error`: error argument - - `bool`: test result - - If the test result is truthy, the function invokes `fcn`; otherwise, the - function invokes the `done` callback. - - The function to invoke is provided two arguments: - - - `i`: iteration number (starting from zero) - - `next`: a callback which must be invoked before proceeding to the next - iteration - - The first argument of the `next` callback is an `error` argument. If `fcn` - calls the `next` callback with a truthy `error` argument, the function - suspends execution and immediately calls the `done` callback for subsequent - `error` handling. - - The `done` callback is invoked with an `error` argument and any arguments - passed to the final `next` callback. - - Execution is *not* guaranteed to be asynchronous. To guarantee asynchrony, - wrap the `done` callback in a function which either executes at the end of - the current stack (e.g., `nextTick`) or during a subsequent turn of the - event loop (e.g., `setImmediate`, `setTimeout`). - - Parameters - ---------- - predicate: Function - The predicate function which indicates whether to continue invoking a - function. - - fcn: Function - The function to invoke. - - done: Function - Callback to invoke upon completion. - - thisArg: any (optional) - Execution context for the invoked function. - - Examples - -------- - > function predicate( i, clbk ) { clbk( null, i < 5 ); }; - > function fcn( i, next ) { - ... setTimeout( onTimeout, i ); - ... function onTimeout() { - ... next( null, 'boop'+i ); - ... } - ... }; - > function done( error, result ) { - ... if ( error ) { - ... throw error; - ... } - ... console.log( result ); - ... }; - > {{alias}}( predicate, fcn, done ) - boop: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4a543d9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,83 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 whileAsync = require( './index' ); - -const fcn = ( i: number, next: Function ): void => { - if ( i === void 0 ) { - throw new Error( '`i` is missing.' ); - } - next(); -}; - -const predicate = ( i: number, clbk: Function ): void => { - clbk( null, i < 5 ); -}; - -const done = ( error: Error | null ): void => { - if ( error ) { - throw error; - } -}; - - -// TESTS // - -// The function returns void... -{ - whileAsync( predicate, fcn, done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a predicate function... -{ - whileAsync( 2, fcn, done ); // $ExpectError - whileAsync( false, fcn, done ); // $ExpectError - whileAsync( true, fcn, done ); // $ExpectError - whileAsync( 'abc', fcn, done ); // $ExpectError - whileAsync( {}, fcn, done ); // $ExpectError - whileAsync( [], fcn, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function having a supported signature... -{ - whileAsync( predicate, 2, done ); // $ExpectError - whileAsync( predicate, false, done ); // $ExpectError - whileAsync( predicate, true, done ); // $ExpectError - whileAsync( predicate, 'abc', done ); // $ExpectError - whileAsync( predicate, {}, done ); // $ExpectError - whileAsync( predicate, [], done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a done callback argument which is not a function having a supported signature... -{ - whileAsync( predicate, fcn, 2 ); // $ExpectError - whileAsync( predicate, fcn, false ); // $ExpectError - whileAsync( predicate, fcn, true ); // $ExpectError - whileAsync( predicate, fcn, 'abc' ); // $ExpectError - whileAsync( predicate, fcn, {} ); // $ExpectError - whileAsync( predicate, fcn, [] ); // $ExpectError - whileAsync( predicate, fcn, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - whileAsync(); // $ExpectError - whileAsync( predicate ); // $ExpectError - whileAsync( predicate, fcn ); // $ExpectError - whileAsync( predicate, fcn, done, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a6af668..0000000 --- a/examples/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var repeatString = require( '@stdlib/string-repeat' ); -var whileAsync = require( './../lib' ); - -function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } -} - -function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, repeatString( 'beep', i+1 ) ); - } -} - -function done( error, result ) { - if ( error ) { - throw error; - } - console.log( result ); -} - -whileAsync( predicate, fcn, done ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..b4c4a89 --- /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-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,e,i,o){var s,l;if(!r(n))throw new TypeError(t("0im3p",n));if(!r(e))throw new TypeError(t("0im2S",e));if(!r(i))throw new TypeError(t("0im3Z",i));function f(r,t){return r?i(r):t?e.call(o,l,m):(s.length&&s.unshift(null),void i.apply(null,s))}function m(r){var t;if(r)return i(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;uLA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a13bd4..0000000 --- a/lib/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Invoke a function while a test condition is true. -* -* @module @stdlib/utils-async-while -* -* @example -* var whileAsync = require( '@stdlib/utils-async-while' ); -* -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c03bb93..0000000 --- a/lib/main.js +++ /dev/null @@ -1,128 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Invokes a function while a test condition is true. -* -* @param {Function} predicate - function which indicates whether to continue invoking a function -* @param {Function} fcn - function to invoke -* @param {Callback} done - callback to invoke upon completion -* @param {*} [thisArg] - execution context for the invoked function -* @throws {TypeError} first argument must be a function -* @throws {TypeError} second argument must be a function -* @throws {TypeError} third argument must be a function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -function whileAsync( predicate, fcn, done, thisArg ) { - var args; - var idx; - if ( !isFunction( predicate ) ) { - throw new TypeError( format( '0im3p', predicate ) ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0im2S', fcn ) ); - } - if ( !isFunction( done ) ) { - throw new TypeError( format( '0im3Z', done ) ); - } - args = []; - idx = 0; - predicate( idx, onPredicate ); - - /** - * Callback invoked upon a predicate result. - * - * @private - * @param {(Error|null)} error - error object - * @param {boolean} result - predicate result - * @returns {void} - */ - function onPredicate( error, result ) { - if ( error ) { - return done( error ); - } - if ( result ) { - return fcn.call( thisArg, idx, next ); - } - if ( args.length ) { - args.unshift( null ); // error argument - } - done.apply( null, args ); - } - - /** - * Callback invoked upon completion of a provided function. - * - * @private - * @param {(Error|null)} error - error object - * @param {...*} results - function results - * @returns {void} - */ - function next( error ) { - var i; - if ( error ) { - return done( error ); - } - idx += 1; - - // Cache the most recent results... - if ( arguments.length > 1 ) { - args = new Array( arguments.length-1 ); - for ( i = 1; i < arguments.length; i++ ) { - args[ i-1 ] = arguments[ i ]; - } - } - // Run the test condition: - predicate( idx, onPredicate ); - } -} - - -// EXPORTS // - -module.exports = whileAsync; diff --git a/package.json b/package.json index fcdbeed..411f4ec 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Invoke a function while a test condition is true.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,35 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/bench": "^0.0.x", - "@stdlib/math-base-assert-is-nan": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "@stdlib/string-repeat": "^0.0.x", - "@stdlib/utils-noop": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-spec": "5.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..d2af97d --- /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 78d0688..0000000 --- a/test/test.js +++ /dev/null @@ -1,328 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 whileAsync = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof whileAsync, 'function', 'main export is a function' ); - t.end(); -}); - -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() { - whileAsync( value, noop, 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() { - whileAsync( noop, value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a callback 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() { - whileAsync( noop, noop, value ); - }; - } -}); - -tape( 'while a test condition is true, the function invokes a provided function', function test( t ) { - var indices1 = [ 0, 1, 2, 3, 4, 5 ]; - var indices2 = [ 0, 1, 2, 3, 4 ]; - var j = -1; - var k = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices1[ j ], 'provides expected value' ); - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - k += 1; - t.strictEqual( i, indices2[ k ], 'provides expected value' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'while a test condition is true, the function invokes a provided function (always false)', function test( t ) { - var indices = [ 0 ]; - var j = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices[ j ], 'provides expected value' ); - clbk( null, false ); - } - - function fcn( i, next ) { - t.fail( 'should never be invoked' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx = { - 'count': 0 - }; - - whileAsync( predicate, fcn, done, ctx ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - this.count += 1; // eslint-disable-line no-invalid-this - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( ctx.count, 5, 'updates context' ); - t.end(); - } -}); - -tape( 'the function provides any results to a `done` callback', function test( t ) { - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, 'beep'+i, 'boop'+i, 'woot'+i ); - } - } - - function done( error, str1, str2, str3 ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( str1, 'beep4', 'returns expected value' ); - t.strictEqual( str2, 'boop4', 'returns expected value' ); - t.strictEqual( str3, 'woot4', 'returns expected value' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the predicate function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - if ( i === 1 ) { - return clbk( new Error( 'beep' ) ); - } - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 2, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the provided function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - if ( i === 2 ) { - return next( new Error( 'boop' ) ); - } - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 3, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'the function does not guarantee asynchronous execution', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - k = 1; - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - next(); - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( k, 0, 'releases the zalgo' ); - t.end(); - } -}); From 6fdac645c0741d5f92a697dd5b4ebb6ae6b4fca3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 00:51:25 +0000 Subject: [PATCH 032/143] 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 1dafc2a..c03bb93 100644 --- a/lib/main.js +++ b/lib/main.js @@ -21,7 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -62,13 +62,13 @@ function whileAsync( predicate, fcn, done, thisArg ) { var args; var idx; if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '0im3p', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0im2S', fcn ) ); } if ( !isFunction( done ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', done ) ); + throw new TypeError( format( '0im3Z', done ) ); } args = []; idx = 0; diff --git a/package.json b/package.json index 59f8c8b..6a82727 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ }, "dependencies": { "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/string-format": "^0.0.x" + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/bench": "^0.0.x", From 22724c36927e76feaed2f5b1f9a3f8a19067d00c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 16:20:45 +0000 Subject: [PATCH 033/143] Remove files --- index.d.ts | 127 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4176 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 b390f4c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,127 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Callback function. -*/ -type Nullary = () => void; - -/** -* Callback function. -* -* @param error - encountered error or null -*/ -type Unary = ( error: Error | null ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Binary = ( error: Error | null, bool: boolean ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Callback = Nullary | Unary | Binary; - -/** -* Callback invoked upon completion. -*/ -type DoneNullary = () => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -*/ -type DoneUnary = ( error: Error | null ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneBinary = ( error: Error | null, ...args: Array ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneCallback = DoneNullary | DoneUnary | DoneBinary; - -/** -* Checks whether an element in a collection passes a test. -* -* @param i - iteration number (starting from one) -* @param clbk - a callback indicating whether to invoke `fcn` -*/ -type Predicate = ( i: number, clbk: Callback ) => void; - -/** -* Invoked function. -* -* @param i - iteration number (starting from zero) -* @param next - a callback which must be invoked before proceeding to the next iteration -*/ -type Fcn = ( i: number, next: Function ) => void; - -/** -* Invokes a function while a test condition is true. -* -* @param predicate - function which indicates whether to continue invoking a function -* @param fcn - function to invoke -* @param done - callback to invoke upon completion -* @param thisArg - execution context for the invoked function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -declare function whileAsync( predicate: Predicate, fcn: Fcn, done: DoneCallback, thisArg?: any ): void; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = whileAsync; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b4c4a89..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-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,e,i,o){var s,l;if(!r(n))throw new TypeError(t("0im3p",n));if(!r(e))throw new TypeError(t("0im2S",e));if(!r(i))throw new TypeError(t("0im3Z",i));function f(r,t){return r?i(r):t?e.call(o,l,m):(s.length&&s.unshift(null),void i.apply(null,s))}function m(r){var t;if(r)return i(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;uLA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index d2af97d..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 4105c9764c217391c2ba70faa88fdaa640d84098 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 16:21:52 +0000 Subject: [PATCH 034/143] 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 | 105 - branches.md | 53 - docs/repl.txt | 72 - docs/types/test.ts | 83 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 57 - lib/main.js | 128 - package.json | 56 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 328 -- 37 files changed, 4069 insertions(+), 3880 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 (100%) 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 7e342af..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-12-01T00:50:49.065Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 0f8dec8..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/async/while) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 d8c823e..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/async/while) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 51569a6..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: '8 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@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 + + ```
@@ -279,7 +272,7 @@ whileAsync( predicate, fcn, done ); ## 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]. @@ -341,13 +334,13 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until +[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until/tree/esm -[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while +[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while/tree/esm -[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until +[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until/tree/esm -[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while +[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index ae9d749..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var whileAsync = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); - -bench( pkg+'::sync_predicate', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 576a70c..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/async/while" -click B href "https://github.com/stdlib-js/utils-async-while/tree/main" -click C href "https://github.com/stdlib-js/utils-async-while/tree/production" -click D href "https://github.com/stdlib-js/utils-async-while/tree/esm" -click E href "https://github.com/stdlib-js/utils-async-while/tree/deno" -click F href "https://github.com/stdlib-js/utils-async-while/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/async/while -[production-url]: https://github.com/stdlib-js/utils-async-while/tree/production -[deno-url]: https://github.com/stdlib-js/utils-async-while/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-async-while/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-async-while/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index d7ca8c9..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,72 +0,0 @@ - -{{alias}}( predicate, fcn, done[, thisArg] ) - Invokes a function while a test condition is true. - - The predicate function is provided two arguments: - - - `i`: iteration number (starting from zero) - - `clbk`: a callback indicating whether to invoke `fcn` - - The `clbk` function accepts two arguments: - - - `error`: error argument - - `bool`: test result - - If the test result is truthy, the function invokes `fcn`; otherwise, the - function invokes the `done` callback. - - The function to invoke is provided two arguments: - - - `i`: iteration number (starting from zero) - - `next`: a callback which must be invoked before proceeding to the next - iteration - - The first argument of the `next` callback is an `error` argument. If `fcn` - calls the `next` callback with a truthy `error` argument, the function - suspends execution and immediately calls the `done` callback for subsequent - `error` handling. - - The `done` callback is invoked with an `error` argument and any arguments - passed to the final `next` callback. - - Execution is *not* guaranteed to be asynchronous. To guarantee asynchrony, - wrap the `done` callback in a function which either executes at the end of - the current stack (e.g., `nextTick`) or during a subsequent turn of the - event loop (e.g., `setImmediate`, `setTimeout`). - - Parameters - ---------- - predicate: Function - The predicate function which indicates whether to continue invoking a - function. - - fcn: Function - The function to invoke. - - done: Function - Callback to invoke upon completion. - - thisArg: any (optional) - Execution context for the invoked function. - - Examples - -------- - > function predicate( i, clbk ) { clbk( null, i < 5 ); }; - > function fcn( i, next ) { - ... setTimeout( onTimeout, i ); - ... function onTimeout() { - ... next( null, 'boop'+i ); - ... } - ... }; - > function done( error, result ) { - ... if ( error ) { - ... throw error; - ... } - ... console.log( result ); - ... }; - > {{alias}}( predicate, fcn, done ) - boop: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4a543d9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,83 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 whileAsync = require( './index' ); - -const fcn = ( i: number, next: Function ): void => { - if ( i === void 0 ) { - throw new Error( '`i` is missing.' ); - } - next(); -}; - -const predicate = ( i: number, clbk: Function ): void => { - clbk( null, i < 5 ); -}; - -const done = ( error: Error | null ): void => { - if ( error ) { - throw error; - } -}; - - -// TESTS // - -// The function returns void... -{ - whileAsync( predicate, fcn, done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a predicate function... -{ - whileAsync( 2, fcn, done ); // $ExpectError - whileAsync( false, fcn, done ); // $ExpectError - whileAsync( true, fcn, done ); // $ExpectError - whileAsync( 'abc', fcn, done ); // $ExpectError - whileAsync( {}, fcn, done ); // $ExpectError - whileAsync( [], fcn, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function having a supported signature... -{ - whileAsync( predicate, 2, done ); // $ExpectError - whileAsync( predicate, false, done ); // $ExpectError - whileAsync( predicate, true, done ); // $ExpectError - whileAsync( predicate, 'abc', done ); // $ExpectError - whileAsync( predicate, {}, done ); // $ExpectError - whileAsync( predicate, [], done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a done callback argument which is not a function having a supported signature... -{ - whileAsync( predicate, fcn, 2 ); // $ExpectError - whileAsync( predicate, fcn, false ); // $ExpectError - whileAsync( predicate, fcn, true ); // $ExpectError - whileAsync( predicate, fcn, 'abc' ); // $ExpectError - whileAsync( predicate, fcn, {} ); // $ExpectError - whileAsync( predicate, fcn, [] ); // $ExpectError - whileAsync( predicate, fcn, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - whileAsync(); // $ExpectError - whileAsync( predicate ); // $ExpectError - whileAsync( predicate, fcn ); // $ExpectError - whileAsync( predicate, fcn, done, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a6af668..0000000 --- a/examples/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var repeatString = require( '@stdlib/string-repeat' ); -var whileAsync = require( './../lib' ); - -function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } -} - -function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, repeatString( 'beep', i+1 ) ); - } -} - -function done( error, result ) { - if ( error ) { - throw error; - } - console.log( result ); -} - -whileAsync( predicate, fcn, done ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..b4c4a89 --- /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-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,e,i,o){var s,l;if(!r(n))throw new TypeError(t("0im3p",n));if(!r(e))throw new TypeError(t("0im2S",e));if(!r(i))throw new TypeError(t("0im3Z",i));function f(r,t){return r?i(r):t?e.call(o,l,m):(s.length&&s.unshift(null),void i.apply(null,s))}function m(r){var t;if(r)return i(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;uLA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a13bd4..0000000 --- a/lib/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Invoke a function while a test condition is true. -* -* @module @stdlib/utils-async-while -* -* @example -* var whileAsync = require( '@stdlib/utils-async-while' ); -* -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c03bb93..0000000 --- a/lib/main.js +++ /dev/null @@ -1,128 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Invokes a function while a test condition is true. -* -* @param {Function} predicate - function which indicates whether to continue invoking a function -* @param {Function} fcn - function to invoke -* @param {Callback} done - callback to invoke upon completion -* @param {*} [thisArg] - execution context for the invoked function -* @throws {TypeError} first argument must be a function -* @throws {TypeError} second argument must be a function -* @throws {TypeError} third argument must be a function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -function whileAsync( predicate, fcn, done, thisArg ) { - var args; - var idx; - if ( !isFunction( predicate ) ) { - throw new TypeError( format( '0im3p', predicate ) ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0im2S', fcn ) ); - } - if ( !isFunction( done ) ) { - throw new TypeError( format( '0im3Z', done ) ); - } - args = []; - idx = 0; - predicate( idx, onPredicate ); - - /** - * Callback invoked upon a predicate result. - * - * @private - * @param {(Error|null)} error - error object - * @param {boolean} result - predicate result - * @returns {void} - */ - function onPredicate( error, result ) { - if ( error ) { - return done( error ); - } - if ( result ) { - return fcn.call( thisArg, idx, next ); - } - if ( args.length ) { - args.unshift( null ); // error argument - } - done.apply( null, args ); - } - - /** - * Callback invoked upon completion of a provided function. - * - * @private - * @param {(Error|null)} error - error object - * @param {...*} results - function results - * @returns {void} - */ - function next( error ) { - var i; - if ( error ) { - return done( error ); - } - idx += 1; - - // Cache the most recent results... - if ( arguments.length > 1 ) { - args = new Array( arguments.length-1 ); - for ( i = 1; i < arguments.length; i++ ) { - args[ i-1 ] = arguments[ i ]; - } - } - // Run the test condition: - predicate( idx, onPredicate ); - } -} - - -// EXPORTS // - -module.exports = whileAsync; diff --git a/package.json b/package.json index 6a82727..411f4ec 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Invoke a function while a test condition is true.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,35 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/bench": "^0.0.x", - "@stdlib/math-base-assert-is-nan": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "@stdlib/string-repeat": "^0.0.x", - "@stdlib/utils-noop": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "2.x.x" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..f000e5b --- /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 78d0688..0000000 --- a/test/test.js +++ /dev/null @@ -1,328 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 whileAsync = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof whileAsync, 'function', 'main export is a function' ); - t.end(); -}); - -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() { - whileAsync( value, noop, 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() { - whileAsync( noop, value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a callback 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() { - whileAsync( noop, noop, value ); - }; - } -}); - -tape( 'while a test condition is true, the function invokes a provided function', function test( t ) { - var indices1 = [ 0, 1, 2, 3, 4, 5 ]; - var indices2 = [ 0, 1, 2, 3, 4 ]; - var j = -1; - var k = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices1[ j ], 'provides expected value' ); - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - k += 1; - t.strictEqual( i, indices2[ k ], 'provides expected value' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'while a test condition is true, the function invokes a provided function (always false)', function test( t ) { - var indices = [ 0 ]; - var j = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices[ j ], 'provides expected value' ); - clbk( null, false ); - } - - function fcn( i, next ) { - t.fail( 'should never be invoked' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx = { - 'count': 0 - }; - - whileAsync( predicate, fcn, done, ctx ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - this.count += 1; // eslint-disable-line no-invalid-this - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( ctx.count, 5, 'updates context' ); - t.end(); - } -}); - -tape( 'the function provides any results to a `done` callback', function test( t ) { - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, 'beep'+i, 'boop'+i, 'woot'+i ); - } - } - - function done( error, str1, str2, str3 ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( str1, 'beep4', 'returns expected value' ); - t.strictEqual( str2, 'boop4', 'returns expected value' ); - t.strictEqual( str3, 'woot4', 'returns expected value' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the predicate function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - if ( i === 1 ) { - return clbk( new Error( 'beep' ) ); - } - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 2, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the provided function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - if ( i === 2 ) { - return next( new Error( 'boop' ) ); - } - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 3, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'the function does not guarantee asynchronous execution', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - k = 1; - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - next(); - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( k, 0, 'releases the zalgo' ); - t.end(); - } -}); From 91c17c2e71dbcf982b98a49a2703cdc84ffa6a14 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Jan 2023 03:34:06 +0000 Subject: [PATCH 035/143] 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 1dafc2a..c03bb93 100644 --- a/lib/main.js +++ b/lib/main.js @@ -21,7 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -62,13 +62,13 @@ function whileAsync( predicate, fcn, done, thisArg ) { var args; var idx; if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '0im3p', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0im2S', fcn ) ); } if ( !isFunction( done ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', done ) ); + throw new TypeError( format( '0im3Z', done ) ); } args = []; idx = 0; diff --git a/package.json b/package.json index 6f30754..bb74266 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ }, "dependencies": { "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/string-format": "^0.0.x" + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/bench": "^0.0.x", From 1e7c2344d618dc4adf445dac1dc6dc799dc4b87f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Jan 2023 08:44:05 +0000 Subject: [PATCH 036/143] Remove files --- index.d.ts | 127 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4176 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 b390f4c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,127 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Callback function. -*/ -type Nullary = () => void; - -/** -* Callback function. -* -* @param error - encountered error or null -*/ -type Unary = ( error: Error | null ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Binary = ( error: Error | null, bool: boolean ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Callback = Nullary | Unary | Binary; - -/** -* Callback invoked upon completion. -*/ -type DoneNullary = () => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -*/ -type DoneUnary = ( error: Error | null ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneBinary = ( error: Error | null, ...args: Array ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneCallback = DoneNullary | DoneUnary | DoneBinary; - -/** -* Checks whether an element in a collection passes a test. -* -* @param i - iteration number (starting from one) -* @param clbk - a callback indicating whether to invoke `fcn` -*/ -type Predicate = ( i: number, clbk: Callback ) => void; - -/** -* Invoked function. -* -* @param i - iteration number (starting from zero) -* @param next - a callback which must be invoked before proceeding to the next iteration -*/ -type Fcn = ( i: number, next: Function ) => void; - -/** -* Invokes a function while a test condition is true. -* -* @param predicate - function which indicates whether to continue invoking a function -* @param fcn - function to invoke -* @param done - callback to invoke upon completion -* @param thisArg - execution context for the invoked function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -declare function whileAsync( predicate: Predicate, fcn: Fcn, done: DoneCallback, thisArg?: any ): void; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = whileAsync; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b4c4a89..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-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,e,i,o){var s,l;if(!r(n))throw new TypeError(t("0im3p",n));if(!r(e))throw new TypeError(t("0im2S",e));if(!r(i))throw new TypeError(t("0im3Z",i));function f(r,t){return r?i(r):t?e.call(o,l,m):(s.length&&s.unshift(null),void i.apply(null,s))}function m(r){var t;if(r)return i(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;uLA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index f000e5b..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 933583cb846f7aba5dcc53466a693e84ab709dc3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Jan 2023 08:45:00 +0000 Subject: [PATCH 037/143] 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 | 105 - branches.md | 53 - docs/repl.txt | 72 - docs/types/test.ts | 83 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 57 - lib/main.js | 128 - package.json | 56 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 328 -- 37 files changed, 4069 insertions(+), 3891 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 (100%) 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 b5fb988..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-01-01T00:41:26.700Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 0f8dec8..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/async/while) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 d8c823e..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/async/while) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 51569a6..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: '8 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@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 + + ```
@@ -279,7 +272,7 @@ whileAsync( predicate, fcn, done ); ## 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]. @@ -341,13 +334,13 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until +[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until/tree/esm -[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while +[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while/tree/esm -[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until +[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until/tree/esm -[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while +[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index ae9d749..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var whileAsync = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); - -bench( pkg+'::sync_predicate', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 576a70c..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/async/while" -click B href "https://github.com/stdlib-js/utils-async-while/tree/main" -click C href "https://github.com/stdlib-js/utils-async-while/tree/production" -click D href "https://github.com/stdlib-js/utils-async-while/tree/esm" -click E href "https://github.com/stdlib-js/utils-async-while/tree/deno" -click F href "https://github.com/stdlib-js/utils-async-while/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/async/while -[production-url]: https://github.com/stdlib-js/utils-async-while/tree/production -[deno-url]: https://github.com/stdlib-js/utils-async-while/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-async-while/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-async-while/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index d7ca8c9..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,72 +0,0 @@ - -{{alias}}( predicate, fcn, done[, thisArg] ) - Invokes a function while a test condition is true. - - The predicate function is provided two arguments: - - - `i`: iteration number (starting from zero) - - `clbk`: a callback indicating whether to invoke `fcn` - - The `clbk` function accepts two arguments: - - - `error`: error argument - - `bool`: test result - - If the test result is truthy, the function invokes `fcn`; otherwise, the - function invokes the `done` callback. - - The function to invoke is provided two arguments: - - - `i`: iteration number (starting from zero) - - `next`: a callback which must be invoked before proceeding to the next - iteration - - The first argument of the `next` callback is an `error` argument. If `fcn` - calls the `next` callback with a truthy `error` argument, the function - suspends execution and immediately calls the `done` callback for subsequent - `error` handling. - - The `done` callback is invoked with an `error` argument and any arguments - passed to the final `next` callback. - - Execution is *not* guaranteed to be asynchronous. To guarantee asynchrony, - wrap the `done` callback in a function which either executes at the end of - the current stack (e.g., `nextTick`) or during a subsequent turn of the - event loop (e.g., `setImmediate`, `setTimeout`). - - Parameters - ---------- - predicate: Function - The predicate function which indicates whether to continue invoking a - function. - - fcn: Function - The function to invoke. - - done: Function - Callback to invoke upon completion. - - thisArg: any (optional) - Execution context for the invoked function. - - Examples - -------- - > function predicate( i, clbk ) { clbk( null, i < 5 ); }; - > function fcn( i, next ) { - ... setTimeout( onTimeout, i ); - ... function onTimeout() { - ... next( null, 'boop'+i ); - ... } - ... }; - > function done( error, result ) { - ... if ( error ) { - ... throw error; - ... } - ... console.log( result ); - ... }; - > {{alias}}( predicate, fcn, done ) - boop: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4a543d9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,83 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 whileAsync = require( './index' ); - -const fcn = ( i: number, next: Function ): void => { - if ( i === void 0 ) { - throw new Error( '`i` is missing.' ); - } - next(); -}; - -const predicate = ( i: number, clbk: Function ): void => { - clbk( null, i < 5 ); -}; - -const done = ( error: Error | null ): void => { - if ( error ) { - throw error; - } -}; - - -// TESTS // - -// The function returns void... -{ - whileAsync( predicate, fcn, done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a predicate function... -{ - whileAsync( 2, fcn, done ); // $ExpectError - whileAsync( false, fcn, done ); // $ExpectError - whileAsync( true, fcn, done ); // $ExpectError - whileAsync( 'abc', fcn, done ); // $ExpectError - whileAsync( {}, fcn, done ); // $ExpectError - whileAsync( [], fcn, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function having a supported signature... -{ - whileAsync( predicate, 2, done ); // $ExpectError - whileAsync( predicate, false, done ); // $ExpectError - whileAsync( predicate, true, done ); // $ExpectError - whileAsync( predicate, 'abc', done ); // $ExpectError - whileAsync( predicate, {}, done ); // $ExpectError - whileAsync( predicate, [], done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a done callback argument which is not a function having a supported signature... -{ - whileAsync( predicate, fcn, 2 ); // $ExpectError - whileAsync( predicate, fcn, false ); // $ExpectError - whileAsync( predicate, fcn, true ); // $ExpectError - whileAsync( predicate, fcn, 'abc' ); // $ExpectError - whileAsync( predicate, fcn, {} ); // $ExpectError - whileAsync( predicate, fcn, [] ); // $ExpectError - whileAsync( predicate, fcn, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - whileAsync(); // $ExpectError - whileAsync( predicate ); // $ExpectError - whileAsync( predicate, fcn ); // $ExpectError - whileAsync( predicate, fcn, done, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a6af668..0000000 --- a/examples/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var repeatString = require( '@stdlib/string-repeat' ); -var whileAsync = require( './../lib' ); - -function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } -} - -function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, repeatString( 'beep', i+1 ) ); - } -} - -function done( error, result ) { - if ( error ) { - throw error; - } - console.log( result ); -} - -whileAsync( predicate, fcn, done ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..d311722 --- /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-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,e,i,o){var s,l;if(!r(n))throw new TypeError(t("0im3p",n));if(!r(e))throw new TypeError(t("0im2S",e));if(!r(i))throw new TypeError(t("0im3Z",i));function f(r,t){return r?i(r):t?e.call(o,l,m):(s.length&&s.unshift(null),void i.apply(null,s))}function m(r){var t;if(r)return i(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;uLA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a13bd4..0000000 --- a/lib/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Invoke a function while a test condition is true. -* -* @module @stdlib/utils-async-while -* -* @example -* var whileAsync = require( '@stdlib/utils-async-while' ); -* -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c03bb93..0000000 --- a/lib/main.js +++ /dev/null @@ -1,128 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Invokes a function while a test condition is true. -* -* @param {Function} predicate - function which indicates whether to continue invoking a function -* @param {Function} fcn - function to invoke -* @param {Callback} done - callback to invoke upon completion -* @param {*} [thisArg] - execution context for the invoked function -* @throws {TypeError} first argument must be a function -* @throws {TypeError} second argument must be a function -* @throws {TypeError} third argument must be a function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -function whileAsync( predicate, fcn, done, thisArg ) { - var args; - var idx; - if ( !isFunction( predicate ) ) { - throw new TypeError( format( '0im3p', predicate ) ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0im2S', fcn ) ); - } - if ( !isFunction( done ) ) { - throw new TypeError( format( '0im3Z', done ) ); - } - args = []; - idx = 0; - predicate( idx, onPredicate ); - - /** - * Callback invoked upon a predicate result. - * - * @private - * @param {(Error|null)} error - error object - * @param {boolean} result - predicate result - * @returns {void} - */ - function onPredicate( error, result ) { - if ( error ) { - return done( error ); - } - if ( result ) { - return fcn.call( thisArg, idx, next ); - } - if ( args.length ) { - args.unshift( null ); // error argument - } - done.apply( null, args ); - } - - /** - * Callback invoked upon completion of a provided function. - * - * @private - * @param {(Error|null)} error - error object - * @param {...*} results - function results - * @returns {void} - */ - function next( error ) { - var i; - if ( error ) { - return done( error ); - } - idx += 1; - - // Cache the most recent results... - if ( arguments.length > 1 ) { - args = new Array( arguments.length-1 ); - for ( i = 1; i < arguments.length; i++ ) { - args[ i-1 ] = arguments[ i ]; - } - } - // Run the test condition: - predicate( idx, onPredicate ); - } -} - - -// EXPORTS // - -module.exports = whileAsync; diff --git a/package.json b/package.json index bb74266..411f4ec 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Invoke a function while a test condition is true.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,35 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/bench": "^0.0.x", - "@stdlib/math-base-assert-is-nan": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "@stdlib/string-repeat": "^0.0.x", - "@stdlib/utils-noop": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..452beab --- /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 78d0688..0000000 --- a/test/test.js +++ /dev/null @@ -1,328 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 whileAsync = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof whileAsync, 'function', 'main export is a function' ); - t.end(); -}); - -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() { - whileAsync( value, noop, 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() { - whileAsync( noop, value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a callback 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() { - whileAsync( noop, noop, value ); - }; - } -}); - -tape( 'while a test condition is true, the function invokes a provided function', function test( t ) { - var indices1 = [ 0, 1, 2, 3, 4, 5 ]; - var indices2 = [ 0, 1, 2, 3, 4 ]; - var j = -1; - var k = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices1[ j ], 'provides expected value' ); - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - k += 1; - t.strictEqual( i, indices2[ k ], 'provides expected value' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'while a test condition is true, the function invokes a provided function (always false)', function test( t ) { - var indices = [ 0 ]; - var j = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices[ j ], 'provides expected value' ); - clbk( null, false ); - } - - function fcn( i, next ) { - t.fail( 'should never be invoked' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx = { - 'count': 0 - }; - - whileAsync( predicate, fcn, done, ctx ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - this.count += 1; // eslint-disable-line no-invalid-this - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( ctx.count, 5, 'updates context' ); - t.end(); - } -}); - -tape( 'the function provides any results to a `done` callback', function test( t ) { - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, 'beep'+i, 'boop'+i, 'woot'+i ); - } - } - - function done( error, str1, str2, str3 ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( str1, 'beep4', 'returns expected value' ); - t.strictEqual( str2, 'boop4', 'returns expected value' ); - t.strictEqual( str3, 'woot4', 'returns expected value' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the predicate function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - if ( i === 1 ) { - return clbk( new Error( 'beep' ) ); - } - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 2, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the provided function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - if ( i === 2 ) { - return next( new Error( 'boop' ) ); - } - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 3, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'the function does not guarantee asynchronous execution', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - k = 1; - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - next(); - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( k, 0, 'releases the zalgo' ); - t.end(); - } -}); From eba3b008d19aa51c1a84820c5af8f1f15e6fb46c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 03:24:59 +0000 Subject: [PATCH 038/143] 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 1dafc2a..c03bb93 100644 --- a/lib/main.js +++ b/lib/main.js @@ -21,7 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -62,13 +62,13 @@ function whileAsync( predicate, fcn, done, thisArg ) { var args; var idx; if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '0im3p', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0im2S', fcn ) ); } if ( !isFunction( done ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', done ) ); + throw new TypeError( format( '0im3Z', done ) ); } args = []; idx = 0; diff --git a/package.json b/package.json index 6f30754..bb74266 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ }, "dependencies": { "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/string-format": "^0.0.x" + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/bench": "^0.0.x", From 054ca7cd0c263cd5cac35a0a9fb8b74a4534cc4c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 11:16:16 +0000 Subject: [PATCH 039/143] Remove files --- index.d.ts | 127 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4176 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 b390f4c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,127 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Callback function. -*/ -type Nullary = () => void; - -/** -* Callback function. -* -* @param error - encountered error or null -*/ -type Unary = ( error: Error | null ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Binary = ( error: Error | null, bool: boolean ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Callback = Nullary | Unary | Binary; - -/** -* Callback invoked upon completion. -*/ -type DoneNullary = () => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -*/ -type DoneUnary = ( error: Error | null ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneBinary = ( error: Error | null, ...args: Array ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneCallback = DoneNullary | DoneUnary | DoneBinary; - -/** -* Checks whether an element in a collection passes a test. -* -* @param i - iteration number (starting from one) -* @param clbk - a callback indicating whether to invoke `fcn` -*/ -type Predicate = ( i: number, clbk: Callback ) => void; - -/** -* Invoked function. -* -* @param i - iteration number (starting from zero) -* @param next - a callback which must be invoked before proceeding to the next iteration -*/ -type Fcn = ( i: number, next: Function ) => void; - -/** -* Invokes a function while a test condition is true. -* -* @param predicate - function which indicates whether to continue invoking a function -* @param fcn - function to invoke -* @param done - callback to invoke upon completion -* @param thisArg - execution context for the invoked function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -declare function whileAsync( predicate: Predicate, fcn: Fcn, done: DoneCallback, thisArg?: any ): void; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = whileAsync; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d311722..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-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,e,i,o){var s,l;if(!r(n))throw new TypeError(t("0im3p",n));if(!r(e))throw new TypeError(t("0im2S",e));if(!r(i))throw new TypeError(t("0im3Z",i));function f(r,t){return r?i(r):t?e.call(o,l,m):(s.length&&s.unshift(null),void i.apply(null,s))}function m(r){var t;if(r)return i(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;uLA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 452beab..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From a5cf9d00112ba4468f7ed6634e3fa5b2b4ee54b9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 11:17:12 +0000 Subject: [PATCH 040/143] 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 | 105 - branches.md | 53 - docs/repl.txt | 72 - docs/types/test.ts | 83 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 57 - lib/main.js | 128 - package.json | 56 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 328 -- 37 files changed, 6202 insertions(+), 3891 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 (100%) 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 9242442..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-02-01T00:48:33.058Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 0f8dec8..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/async/while) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 d8c823e..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/async/while) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 51569a6..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: '8 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@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 + + ```
@@ -279,7 +272,7 @@ whileAsync( predicate, fcn, done ); ## 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]. @@ -341,13 +334,13 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until +[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until/tree/esm -[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while +[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while/tree/esm -[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until +[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until/tree/esm -[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while +[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index ae9d749..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var whileAsync = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); - -bench( pkg+'::sync_predicate', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 576a70c..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/async/while" -click B href "https://github.com/stdlib-js/utils-async-while/tree/main" -click C href "https://github.com/stdlib-js/utils-async-while/tree/production" -click D href "https://github.com/stdlib-js/utils-async-while/tree/esm" -click E href "https://github.com/stdlib-js/utils-async-while/tree/deno" -click F href "https://github.com/stdlib-js/utils-async-while/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/async/while -[production-url]: https://github.com/stdlib-js/utils-async-while/tree/production -[deno-url]: https://github.com/stdlib-js/utils-async-while/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-async-while/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-async-while/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index d7ca8c9..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,72 +0,0 @@ - -{{alias}}( predicate, fcn, done[, thisArg] ) - Invokes a function while a test condition is true. - - The predicate function is provided two arguments: - - - `i`: iteration number (starting from zero) - - `clbk`: a callback indicating whether to invoke `fcn` - - The `clbk` function accepts two arguments: - - - `error`: error argument - - `bool`: test result - - If the test result is truthy, the function invokes `fcn`; otherwise, the - function invokes the `done` callback. - - The function to invoke is provided two arguments: - - - `i`: iteration number (starting from zero) - - `next`: a callback which must be invoked before proceeding to the next - iteration - - The first argument of the `next` callback is an `error` argument. If `fcn` - calls the `next` callback with a truthy `error` argument, the function - suspends execution and immediately calls the `done` callback for subsequent - `error` handling. - - The `done` callback is invoked with an `error` argument and any arguments - passed to the final `next` callback. - - Execution is *not* guaranteed to be asynchronous. To guarantee asynchrony, - wrap the `done` callback in a function which either executes at the end of - the current stack (e.g., `nextTick`) or during a subsequent turn of the - event loop (e.g., `setImmediate`, `setTimeout`). - - Parameters - ---------- - predicate: Function - The predicate function which indicates whether to continue invoking a - function. - - fcn: Function - The function to invoke. - - done: Function - Callback to invoke upon completion. - - thisArg: any (optional) - Execution context for the invoked function. - - Examples - -------- - > function predicate( i, clbk ) { clbk( null, i < 5 ); }; - > function fcn( i, next ) { - ... setTimeout( onTimeout, i ); - ... function onTimeout() { - ... next( null, 'boop'+i ); - ... } - ... }; - > function done( error, result ) { - ... if ( error ) { - ... throw error; - ... } - ... console.log( result ); - ... }; - > {{alias}}( predicate, fcn, done ) - boop: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4a543d9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,83 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 whileAsync = require( './index' ); - -const fcn = ( i: number, next: Function ): void => { - if ( i === void 0 ) { - throw new Error( '`i` is missing.' ); - } - next(); -}; - -const predicate = ( i: number, clbk: Function ): void => { - clbk( null, i < 5 ); -}; - -const done = ( error: Error | null ): void => { - if ( error ) { - throw error; - } -}; - - -// TESTS // - -// The function returns void... -{ - whileAsync( predicate, fcn, done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a predicate function... -{ - whileAsync( 2, fcn, done ); // $ExpectError - whileAsync( false, fcn, done ); // $ExpectError - whileAsync( true, fcn, done ); // $ExpectError - whileAsync( 'abc', fcn, done ); // $ExpectError - whileAsync( {}, fcn, done ); // $ExpectError - whileAsync( [], fcn, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function having a supported signature... -{ - whileAsync( predicate, 2, done ); // $ExpectError - whileAsync( predicate, false, done ); // $ExpectError - whileAsync( predicate, true, done ); // $ExpectError - whileAsync( predicate, 'abc', done ); // $ExpectError - whileAsync( predicate, {}, done ); // $ExpectError - whileAsync( predicate, [], done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a done callback argument which is not a function having a supported signature... -{ - whileAsync( predicate, fcn, 2 ); // $ExpectError - whileAsync( predicate, fcn, false ); // $ExpectError - whileAsync( predicate, fcn, true ); // $ExpectError - whileAsync( predicate, fcn, 'abc' ); // $ExpectError - whileAsync( predicate, fcn, {} ); // $ExpectError - whileAsync( predicate, fcn, [] ); // $ExpectError - whileAsync( predicate, fcn, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - whileAsync(); // $ExpectError - whileAsync( predicate ); // $ExpectError - whileAsync( predicate, fcn ); // $ExpectError - whileAsync( predicate, fcn, done, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a6af668..0000000 --- a/examples/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var repeatString = require( '@stdlib/string-repeat' ); -var whileAsync = require( './../lib' ); - -function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } -} - -function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, repeatString( 'beep', i+1 ) ); - } -} - -function done( error, result ) { - if ( error ) { - throw error; - } - console.log( result ); -} - -whileAsync( predicate, fcn, done ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..d311722 --- /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-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,e,i,o){var s,l;if(!r(n))throw new TypeError(t("0im3p",n));if(!r(e))throw new TypeError(t("0im2S",e));if(!r(i))throw new TypeError(t("0im3Z",i));function f(r,t){return r?i(r):t?e.call(o,l,m):(s.length&&s.unshift(null),void i.apply(null,s))}function m(r){var t;if(r)return i(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;uLA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a13bd4..0000000 --- a/lib/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Invoke a function while a test condition is true. -* -* @module @stdlib/utils-async-while -* -* @example -* var whileAsync = require( '@stdlib/utils-async-while' ); -* -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c03bb93..0000000 --- a/lib/main.js +++ /dev/null @@ -1,128 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Invokes a function while a test condition is true. -* -* @param {Function} predicate - function which indicates whether to continue invoking a function -* @param {Function} fcn - function to invoke -* @param {Callback} done - callback to invoke upon completion -* @param {*} [thisArg] - execution context for the invoked function -* @throws {TypeError} first argument must be a function -* @throws {TypeError} second argument must be a function -* @throws {TypeError} third argument must be a function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -function whileAsync( predicate, fcn, done, thisArg ) { - var args; - var idx; - if ( !isFunction( predicate ) ) { - throw new TypeError( format( '0im3p', predicate ) ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0im2S', fcn ) ); - } - if ( !isFunction( done ) ) { - throw new TypeError( format( '0im3Z', done ) ); - } - args = []; - idx = 0; - predicate( idx, onPredicate ); - - /** - * Callback invoked upon a predicate result. - * - * @private - * @param {(Error|null)} error - error object - * @param {boolean} result - predicate result - * @returns {void} - */ - function onPredicate( error, result ) { - if ( error ) { - return done( error ); - } - if ( result ) { - return fcn.call( thisArg, idx, next ); - } - if ( args.length ) { - args.unshift( null ); // error argument - } - done.apply( null, args ); - } - - /** - * Callback invoked upon completion of a provided function. - * - * @private - * @param {(Error|null)} error - error object - * @param {...*} results - function results - * @returns {void} - */ - function next( error ) { - var i; - if ( error ) { - return done( error ); - } - idx += 1; - - // Cache the most recent results... - if ( arguments.length > 1 ) { - args = new Array( arguments.length-1 ); - for ( i = 1; i < arguments.length; i++ ) { - args[ i-1 ] = arguments[ i ]; - } - } - // Run the test condition: - predicate( idx, onPredicate ); - } -} - - -// EXPORTS // - -module.exports = whileAsync; diff --git a/package.json b/package.json index bb74266..411f4ec 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Invoke a function while a test condition is true.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,35 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/bench": "^0.0.x", - "@stdlib/math-base-assert-is-nan": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "@stdlib/string-repeat": "^0.0.x", - "@stdlib/utils-noop": "^0.0.x", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..8385c59 --- /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 78d0688..0000000 --- a/test/test.js +++ /dev/null @@ -1,328 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 whileAsync = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof whileAsync, 'function', 'main export is a function' ); - t.end(); -}); - -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() { - whileAsync( value, noop, 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() { - whileAsync( noop, value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a callback 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() { - whileAsync( noop, noop, value ); - }; - } -}); - -tape( 'while a test condition is true, the function invokes a provided function', function test( t ) { - var indices1 = [ 0, 1, 2, 3, 4, 5 ]; - var indices2 = [ 0, 1, 2, 3, 4 ]; - var j = -1; - var k = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices1[ j ], 'provides expected value' ); - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - k += 1; - t.strictEqual( i, indices2[ k ], 'provides expected value' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'while a test condition is true, the function invokes a provided function (always false)', function test( t ) { - var indices = [ 0 ]; - var j = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices[ j ], 'provides expected value' ); - clbk( null, false ); - } - - function fcn( i, next ) { - t.fail( 'should never be invoked' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx = { - 'count': 0 - }; - - whileAsync( predicate, fcn, done, ctx ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - this.count += 1; // eslint-disable-line no-invalid-this - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( ctx.count, 5, 'updates context' ); - t.end(); - } -}); - -tape( 'the function provides any results to a `done` callback', function test( t ) { - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, 'beep'+i, 'boop'+i, 'woot'+i ); - } - } - - function done( error, str1, str2, str3 ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( str1, 'beep4', 'returns expected value' ); - t.strictEqual( str2, 'boop4', 'returns expected value' ); - t.strictEqual( str3, 'woot4', 'returns expected value' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the predicate function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - if ( i === 1 ) { - return clbk( new Error( 'beep' ) ); - } - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 2, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the provided function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - if ( i === 2 ) { - return next( new Error( 'boop' ) ); - } - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 3, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'the function does not guarantee asynchronous execution', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - k = 1; - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - next(); - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( k, 0, 'releases the zalgo' ); - t.end(); - } -}); From dd9c04fad9dc9f406640a2a581dab1eb64ed0a81 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Mar 2023 01:40:53 +0000 Subject: [PATCH 041/143] 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 1dafc2a..c03bb93 100644 --- a/lib/main.js +++ b/lib/main.js @@ -21,7 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -62,13 +62,13 @@ function whileAsync( predicate, fcn, done, thisArg ) { var args; var idx; if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '0im3p', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0im2S', fcn ) ); } if ( !isFunction( done ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', done ) ); + throw new TypeError( format( '0im3Z', done ) ); } args = []; idx = 0; diff --git a/package.json b/package.json index 50a2ee9..fca61ba 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ }, "dependencies": { "@stdlib/assert-is-function": "^0.0.8", - "@stdlib/string-format": "^0.0.3" + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/bench": "^0.0.12", From 81fa60a39bbfc496b6865990afee6612ce4b47d4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Mar 2023 04:04:27 +0000 Subject: [PATCH 042/143] Remove files --- index.d.ts | 127 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6309 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 b390f4c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,127 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Callback function. -*/ -type Nullary = () => void; - -/** -* Callback function. -* -* @param error - encountered error or null -*/ -type Unary = ( error: Error | null ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Binary = ( error: Error | null, bool: boolean ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Callback = Nullary | Unary | Binary; - -/** -* Callback invoked upon completion. -*/ -type DoneNullary = () => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -*/ -type DoneUnary = ( error: Error | null ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneBinary = ( error: Error | null, ...args: Array ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneCallback = DoneNullary | DoneUnary | DoneBinary; - -/** -* Checks whether an element in a collection passes a test. -* -* @param i - iteration number (starting from one) -* @param clbk - a callback indicating whether to invoke `fcn` -*/ -type Predicate = ( i: number, clbk: Callback ) => void; - -/** -* Invoked function. -* -* @param i - iteration number (starting from zero) -* @param next - a callback which must be invoked before proceeding to the next iteration -*/ -type Fcn = ( i: number, next: Function ) => void; - -/** -* Invokes a function while a test condition is true. -* -* @param predicate - function which indicates whether to continue invoking a function -* @param fcn - function to invoke -* @param done - callback to invoke upon completion -* @param thisArg - execution context for the invoked function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -declare function whileAsync( predicate: Predicate, fcn: Fcn, done: DoneCallback, thisArg?: any ): void; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = whileAsync; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d311722..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-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,e,i,o){var s,l;if(!r(n))throw new TypeError(t("0im3p",n));if(!r(e))throw new TypeError(t("0im2S",e));if(!r(i))throw new TypeError(t("0im3Z",i));function f(r,t){return r?i(r):t?e.call(o,l,m):(s.length&&s.unshift(null),void i.apply(null,s))}function m(r){var t;if(r)return i(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;uLA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 8385c59..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 630ade2c67caf6d916683efa3a27072188d8ac5a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Mar 2023 04:05:14 +0000 Subject: [PATCH 043/143] 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 | 105 - branches.md | 53 - docs/repl.txt | 72 - docs/types/test.ts | 83 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 57 - lib/main.js | 128 - package.json | 56 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 328 -- 37 files changed, 6202 insertions(+), 4026 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 (100%) 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 c83df70..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-03-01T01:10:01.421Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 0f8dec8..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/async/while) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 d8c823e..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/async/while) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 51569a6..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: '8 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@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 + + ```
@@ -279,7 +272,7 @@ whileAsync( predicate, fcn, done ); ## 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]. @@ -341,13 +334,13 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until +[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until/tree/esm -[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while +[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while/tree/esm -[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until +[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until/tree/esm -[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while +[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index ae9d749..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var whileAsync = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); - -bench( pkg+'::sync_predicate', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1e936a1..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/async/while" -%% click B href "https://github.com/stdlib-js/utils-async-while/tree/main" -%% click C href "https://github.com/stdlib-js/utils-async-while/tree/production" -%% click D href "https://github.com/stdlib-js/utils-async-while/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-async-while/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-async-while/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/async/while -[production-url]: https://github.com/stdlib-js/utils-async-while/tree/production -[deno-url]: https://github.com/stdlib-js/utils-async-while/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-async-while/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-async-while/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index d7ca8c9..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,72 +0,0 @@ - -{{alias}}( predicate, fcn, done[, thisArg] ) - Invokes a function while a test condition is true. - - The predicate function is provided two arguments: - - - `i`: iteration number (starting from zero) - - `clbk`: a callback indicating whether to invoke `fcn` - - The `clbk` function accepts two arguments: - - - `error`: error argument - - `bool`: test result - - If the test result is truthy, the function invokes `fcn`; otherwise, the - function invokes the `done` callback. - - The function to invoke is provided two arguments: - - - `i`: iteration number (starting from zero) - - `next`: a callback which must be invoked before proceeding to the next - iteration - - The first argument of the `next` callback is an `error` argument. If `fcn` - calls the `next` callback with a truthy `error` argument, the function - suspends execution and immediately calls the `done` callback for subsequent - `error` handling. - - The `done` callback is invoked with an `error` argument and any arguments - passed to the final `next` callback. - - Execution is *not* guaranteed to be asynchronous. To guarantee asynchrony, - wrap the `done` callback in a function which either executes at the end of - the current stack (e.g., `nextTick`) or during a subsequent turn of the - event loop (e.g., `setImmediate`, `setTimeout`). - - Parameters - ---------- - predicate: Function - The predicate function which indicates whether to continue invoking a - function. - - fcn: Function - The function to invoke. - - done: Function - Callback to invoke upon completion. - - thisArg: any (optional) - Execution context for the invoked function. - - Examples - -------- - > function predicate( i, clbk ) { clbk( null, i < 5 ); }; - > function fcn( i, next ) { - ... setTimeout( onTimeout, i ); - ... function onTimeout() { - ... next( null, 'boop'+i ); - ... } - ... }; - > function done( error, result ) { - ... if ( error ) { - ... throw error; - ... } - ... console.log( result ); - ... }; - > {{alias}}( predicate, fcn, done ) - boop: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4a543d9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,83 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 whileAsync = require( './index' ); - -const fcn = ( i: number, next: Function ): void => { - if ( i === void 0 ) { - throw new Error( '`i` is missing.' ); - } - next(); -}; - -const predicate = ( i: number, clbk: Function ): void => { - clbk( null, i < 5 ); -}; - -const done = ( error: Error | null ): void => { - if ( error ) { - throw error; - } -}; - - -// TESTS // - -// The function returns void... -{ - whileAsync( predicate, fcn, done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a predicate function... -{ - whileAsync( 2, fcn, done ); // $ExpectError - whileAsync( false, fcn, done ); // $ExpectError - whileAsync( true, fcn, done ); // $ExpectError - whileAsync( 'abc', fcn, done ); // $ExpectError - whileAsync( {}, fcn, done ); // $ExpectError - whileAsync( [], fcn, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function having a supported signature... -{ - whileAsync( predicate, 2, done ); // $ExpectError - whileAsync( predicate, false, done ); // $ExpectError - whileAsync( predicate, true, done ); // $ExpectError - whileAsync( predicate, 'abc', done ); // $ExpectError - whileAsync( predicate, {}, done ); // $ExpectError - whileAsync( predicate, [], done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a done callback argument which is not a function having a supported signature... -{ - whileAsync( predicate, fcn, 2 ); // $ExpectError - whileAsync( predicate, fcn, false ); // $ExpectError - whileAsync( predicate, fcn, true ); // $ExpectError - whileAsync( predicate, fcn, 'abc' ); // $ExpectError - whileAsync( predicate, fcn, {} ); // $ExpectError - whileAsync( predicate, fcn, [] ); // $ExpectError - whileAsync( predicate, fcn, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - whileAsync(); // $ExpectError - whileAsync( predicate ); // $ExpectError - whileAsync( predicate, fcn ); // $ExpectError - whileAsync( predicate, fcn, done, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a6af668..0000000 --- a/examples/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var repeatString = require( '@stdlib/string-repeat' ); -var whileAsync = require( './../lib' ); - -function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } -} - -function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, repeatString( 'beep', i+1 ) ); - } -} - -function done( error, result ) { - if ( error ) { - throw error; - } - console.log( result ); -} - -whileAsync( predicate, fcn, done ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..d311722 --- /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-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,e,i,o){var s,l;if(!r(n))throw new TypeError(t("0im3p",n));if(!r(e))throw new TypeError(t("0im2S",e));if(!r(i))throw new TypeError(t("0im3Z",i));function f(r,t){return r?i(r):t?e.call(o,l,m):(s.length&&s.unshift(null),void i.apply(null,s))}function m(r){var t;if(r)return i(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;uLA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a13bd4..0000000 --- a/lib/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Invoke a function while a test condition is true. -* -* @module @stdlib/utils-async-while -* -* @example -* var whileAsync = require( '@stdlib/utils-async-while' ); -* -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c03bb93..0000000 --- a/lib/main.js +++ /dev/null @@ -1,128 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Invokes a function while a test condition is true. -* -* @param {Function} predicate - function which indicates whether to continue invoking a function -* @param {Function} fcn - function to invoke -* @param {Callback} done - callback to invoke upon completion -* @param {*} [thisArg] - execution context for the invoked function -* @throws {TypeError} first argument must be a function -* @throws {TypeError} second argument must be a function -* @throws {TypeError} third argument must be a function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -function whileAsync( predicate, fcn, done, thisArg ) { - var args; - var idx; - if ( !isFunction( predicate ) ) { - throw new TypeError( format( '0im3p', predicate ) ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0im2S', fcn ) ); - } - if ( !isFunction( done ) ) { - throw new TypeError( format( '0im3Z', done ) ); - } - args = []; - idx = 0; - predicate( idx, onPredicate ); - - /** - * Callback invoked upon a predicate result. - * - * @private - * @param {(Error|null)} error - error object - * @param {boolean} result - predicate result - * @returns {void} - */ - function onPredicate( error, result ) { - if ( error ) { - return done( error ); - } - if ( result ) { - return fcn.call( thisArg, idx, next ); - } - if ( args.length ) { - args.unshift( null ); // error argument - } - done.apply( null, args ); - } - - /** - * Callback invoked upon completion of a provided function. - * - * @private - * @param {(Error|null)} error - error object - * @param {...*} results - function results - * @returns {void} - */ - function next( error ) { - var i; - if ( error ) { - return done( error ); - } - idx += 1; - - // Cache the most recent results... - if ( arguments.length > 1 ) { - args = new Array( arguments.length-1 ); - for ( i = 1; i < arguments.length; i++ ) { - args[ i-1 ] = arguments[ i ]; - } - } - // Run the test condition: - predicate( idx, onPredicate ); - } -} - - -// EXPORTS // - -module.exports = whileAsync; diff --git a/package.json b/package.json index fca61ba..0652b06 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Invoke a function while a test condition is true.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,35 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.0.8", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/bench": "^0.0.12", - "@stdlib/math-base-assert-is-nan": "^0.0.8", - "@stdlib/random-base-randu": "^0.0.8", - "@stdlib/string-repeat": "^0.0.9", - "@stdlib/utils-noop": "^0.0.14", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..9dc8c8b --- /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 78d0688..0000000 --- a/test/test.js +++ /dev/null @@ -1,328 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 whileAsync = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof whileAsync, 'function', 'main export is a function' ); - t.end(); -}); - -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() { - whileAsync( value, noop, 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() { - whileAsync( noop, value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a callback 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() { - whileAsync( noop, noop, value ); - }; - } -}); - -tape( 'while a test condition is true, the function invokes a provided function', function test( t ) { - var indices1 = [ 0, 1, 2, 3, 4, 5 ]; - var indices2 = [ 0, 1, 2, 3, 4 ]; - var j = -1; - var k = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices1[ j ], 'provides expected value' ); - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - k += 1; - t.strictEqual( i, indices2[ k ], 'provides expected value' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'while a test condition is true, the function invokes a provided function (always false)', function test( t ) { - var indices = [ 0 ]; - var j = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices[ j ], 'provides expected value' ); - clbk( null, false ); - } - - function fcn( i, next ) { - t.fail( 'should never be invoked' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx = { - 'count': 0 - }; - - whileAsync( predicate, fcn, done, ctx ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - this.count += 1; // eslint-disable-line no-invalid-this - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( ctx.count, 5, 'updates context' ); - t.end(); - } -}); - -tape( 'the function provides any results to a `done` callback', function test( t ) { - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, 'beep'+i, 'boop'+i, 'woot'+i ); - } - } - - function done( error, str1, str2, str3 ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( str1, 'beep4', 'returns expected value' ); - t.strictEqual( str2, 'boop4', 'returns expected value' ); - t.strictEqual( str3, 'woot4', 'returns expected value' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the predicate function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - if ( i === 1 ) { - return clbk( new Error( 'beep' ) ); - } - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 2, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the provided function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - if ( i === 2 ) { - return next( new Error( 'boop' ) ); - } - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 3, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'the function does not guarantee asynchronous execution', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - k = 1; - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - next(); - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( k, 0, 'releases the zalgo' ); - t.end(); - } -}); From 0e5f160c5ef5b89ec425210dbec7565989241796 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Apr 2023 01:42:28 +0000 Subject: [PATCH 044/143] 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 1dafc2a..c03bb93 100644 --- a/lib/main.js +++ b/lib/main.js @@ -21,7 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -62,13 +62,13 @@ function whileAsync( predicate, fcn, done, thisArg ) { var args; var idx; if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '0im3p', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0im2S', fcn ) ); } if ( !isFunction( done ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', done ) ); + throw new TypeError( format( '0im3Z', done ) ); } args = []; idx = 0; diff --git a/package.json b/package.json index 50a2ee9..fca61ba 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ }, "dependencies": { "@stdlib/assert-is-function": "^0.0.8", - "@stdlib/string-format": "^0.0.3" + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/bench": "^0.0.12", From 9daceb9a08371f494ac9b0116f937e952c2fdbf4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Apr 2023 03:47:54 +0000 Subject: [PATCH 045/143] Remove files --- index.d.ts | 127 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6309 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 b390f4c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,127 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Callback function. -*/ -type Nullary = () => void; - -/** -* Callback function. -* -* @param error - encountered error or null -*/ -type Unary = ( error: Error | null ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Binary = ( error: Error | null, bool: boolean ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Callback = Nullary | Unary | Binary; - -/** -* Callback invoked upon completion. -*/ -type DoneNullary = () => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -*/ -type DoneUnary = ( error: Error | null ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneBinary = ( error: Error | null, ...args: Array ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneCallback = DoneNullary | DoneUnary | DoneBinary; - -/** -* Checks whether an element in a collection passes a test. -* -* @param i - iteration number (starting from one) -* @param clbk - a callback indicating whether to invoke `fcn` -*/ -type Predicate = ( i: number, clbk: Callback ) => void; - -/** -* Invoked function. -* -* @param i - iteration number (starting from zero) -* @param next - a callback which must be invoked before proceeding to the next iteration -*/ -type Fcn = ( i: number, next: Function ) => void; - -/** -* Invokes a function while a test condition is true. -* -* @param predicate - function which indicates whether to continue invoking a function -* @param fcn - function to invoke -* @param done - callback to invoke upon completion -* @param thisArg - execution context for the invoked function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -declare function whileAsync( predicate: Predicate, fcn: Fcn, done: DoneCallback, thisArg?: any ): void; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = whileAsync; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d311722..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-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,e,i,o){var s,l;if(!r(n))throw new TypeError(t("0im3p",n));if(!r(e))throw new TypeError(t("0im2S",e));if(!r(i))throw new TypeError(t("0im3Z",i));function f(r,t){return r?i(r):t?e.call(o,l,m):(s.length&&s.unshift(null),void i.apply(null,s))}function m(r){var t;if(r)return i(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;uLA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 9dc8c8b..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 153a00dd6a8ffe428a95e1dd529fd47c8fa4a3ec Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Apr 2023 03:48:44 +0000 Subject: [PATCH 046/143] 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 | 105 - branches.md | 53 - docs/repl.txt | 72 - docs/types/test.ts | 83 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 57 - lib/main.js | 128 - package.json | 56 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 328 -- 37 files changed, 6202 insertions(+), 4032 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 (100%) 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 af6c776..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-04-01T01:11:38.397Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 0f8dec8..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/async/while) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 d8c823e..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/async/while) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 51569a6..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: '8 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@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 + + ```
@@ -279,7 +272,7 @@ whileAsync( predicate, fcn, done ); ## 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]. @@ -341,13 +334,13 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until +[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until/tree/esm -[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while +[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while/tree/esm -[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until +[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until/tree/esm -[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while +[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index ae9d749..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var whileAsync = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); - -bench( pkg+'::sync_predicate', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1e936a1..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/async/while" -%% click B href "https://github.com/stdlib-js/utils-async-while/tree/main" -%% click C href "https://github.com/stdlib-js/utils-async-while/tree/production" -%% click D href "https://github.com/stdlib-js/utils-async-while/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-async-while/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-async-while/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/async/while -[production-url]: https://github.com/stdlib-js/utils-async-while/tree/production -[deno-url]: https://github.com/stdlib-js/utils-async-while/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-async-while/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-async-while/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index d7ca8c9..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,72 +0,0 @@ - -{{alias}}( predicate, fcn, done[, thisArg] ) - Invokes a function while a test condition is true. - - The predicate function is provided two arguments: - - - `i`: iteration number (starting from zero) - - `clbk`: a callback indicating whether to invoke `fcn` - - The `clbk` function accepts two arguments: - - - `error`: error argument - - `bool`: test result - - If the test result is truthy, the function invokes `fcn`; otherwise, the - function invokes the `done` callback. - - The function to invoke is provided two arguments: - - - `i`: iteration number (starting from zero) - - `next`: a callback which must be invoked before proceeding to the next - iteration - - The first argument of the `next` callback is an `error` argument. If `fcn` - calls the `next` callback with a truthy `error` argument, the function - suspends execution and immediately calls the `done` callback for subsequent - `error` handling. - - The `done` callback is invoked with an `error` argument and any arguments - passed to the final `next` callback. - - Execution is *not* guaranteed to be asynchronous. To guarantee asynchrony, - wrap the `done` callback in a function which either executes at the end of - the current stack (e.g., `nextTick`) or during a subsequent turn of the - event loop (e.g., `setImmediate`, `setTimeout`). - - Parameters - ---------- - predicate: Function - The predicate function which indicates whether to continue invoking a - function. - - fcn: Function - The function to invoke. - - done: Function - Callback to invoke upon completion. - - thisArg: any (optional) - Execution context for the invoked function. - - Examples - -------- - > function predicate( i, clbk ) { clbk( null, i < 5 ); }; - > function fcn( i, next ) { - ... setTimeout( onTimeout, i ); - ... function onTimeout() { - ... next( null, 'boop'+i ); - ... } - ... }; - > function done( error, result ) { - ... if ( error ) { - ... throw error; - ... } - ... console.log( result ); - ... }; - > {{alias}}( predicate, fcn, done ) - boop: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4a543d9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,83 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 whileAsync = require( './index' ); - -const fcn = ( i: number, next: Function ): void => { - if ( i === void 0 ) { - throw new Error( '`i` is missing.' ); - } - next(); -}; - -const predicate = ( i: number, clbk: Function ): void => { - clbk( null, i < 5 ); -}; - -const done = ( error: Error | null ): void => { - if ( error ) { - throw error; - } -}; - - -// TESTS // - -// The function returns void... -{ - whileAsync( predicate, fcn, done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a predicate function... -{ - whileAsync( 2, fcn, done ); // $ExpectError - whileAsync( false, fcn, done ); // $ExpectError - whileAsync( true, fcn, done ); // $ExpectError - whileAsync( 'abc', fcn, done ); // $ExpectError - whileAsync( {}, fcn, done ); // $ExpectError - whileAsync( [], fcn, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function having a supported signature... -{ - whileAsync( predicate, 2, done ); // $ExpectError - whileAsync( predicate, false, done ); // $ExpectError - whileAsync( predicate, true, done ); // $ExpectError - whileAsync( predicate, 'abc', done ); // $ExpectError - whileAsync( predicate, {}, done ); // $ExpectError - whileAsync( predicate, [], done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a done callback argument which is not a function having a supported signature... -{ - whileAsync( predicate, fcn, 2 ); // $ExpectError - whileAsync( predicate, fcn, false ); // $ExpectError - whileAsync( predicate, fcn, true ); // $ExpectError - whileAsync( predicate, fcn, 'abc' ); // $ExpectError - whileAsync( predicate, fcn, {} ); // $ExpectError - whileAsync( predicate, fcn, [] ); // $ExpectError - whileAsync( predicate, fcn, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - whileAsync(); // $ExpectError - whileAsync( predicate ); // $ExpectError - whileAsync( predicate, fcn ); // $ExpectError - whileAsync( predicate, fcn, done, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a6af668..0000000 --- a/examples/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var repeatString = require( '@stdlib/string-repeat' ); -var whileAsync = require( './../lib' ); - -function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } -} - -function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, repeatString( 'beep', i+1 ) ); - } -} - -function done( error, result ) { - if ( error ) { - throw error; - } - console.log( result ); -} - -whileAsync( predicate, fcn, done ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..d311722 --- /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-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,e,i,o){var s,l;if(!r(n))throw new TypeError(t("0im3p",n));if(!r(e))throw new TypeError(t("0im2S",e));if(!r(i))throw new TypeError(t("0im3Z",i));function f(r,t){return r?i(r):t?e.call(o,l,m):(s.length&&s.unshift(null),void i.apply(null,s))}function m(r){var t;if(r)return i(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;uLA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a13bd4..0000000 --- a/lib/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Invoke a function while a test condition is true. -* -* @module @stdlib/utils-async-while -* -* @example -* var whileAsync = require( '@stdlib/utils-async-while' ); -* -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c03bb93..0000000 --- a/lib/main.js +++ /dev/null @@ -1,128 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Invokes a function while a test condition is true. -* -* @param {Function} predicate - function which indicates whether to continue invoking a function -* @param {Function} fcn - function to invoke -* @param {Callback} done - callback to invoke upon completion -* @param {*} [thisArg] - execution context for the invoked function -* @throws {TypeError} first argument must be a function -* @throws {TypeError} second argument must be a function -* @throws {TypeError} third argument must be a function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -function whileAsync( predicate, fcn, done, thisArg ) { - var args; - var idx; - if ( !isFunction( predicate ) ) { - throw new TypeError( format( '0im3p', predicate ) ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0im2S', fcn ) ); - } - if ( !isFunction( done ) ) { - throw new TypeError( format( '0im3Z', done ) ); - } - args = []; - idx = 0; - predicate( idx, onPredicate ); - - /** - * Callback invoked upon a predicate result. - * - * @private - * @param {(Error|null)} error - error object - * @param {boolean} result - predicate result - * @returns {void} - */ - function onPredicate( error, result ) { - if ( error ) { - return done( error ); - } - if ( result ) { - return fcn.call( thisArg, idx, next ); - } - if ( args.length ) { - args.unshift( null ); // error argument - } - done.apply( null, args ); - } - - /** - * Callback invoked upon completion of a provided function. - * - * @private - * @param {(Error|null)} error - error object - * @param {...*} results - function results - * @returns {void} - */ - function next( error ) { - var i; - if ( error ) { - return done( error ); - } - idx += 1; - - // Cache the most recent results... - if ( arguments.length > 1 ) { - args = new Array( arguments.length-1 ); - for ( i = 1; i < arguments.length; i++ ) { - args[ i-1 ] = arguments[ i ]; - } - } - // Run the test condition: - predicate( idx, onPredicate ); - } -} - - -// EXPORTS // - -module.exports = whileAsync; diff --git a/package.json b/package.json index fca61ba..0652b06 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Invoke a function while a test condition is true.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,35 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.0.8", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/bench": "^0.0.12", - "@stdlib/math-base-assert-is-nan": "^0.0.8", - "@stdlib/random-base-randu": "^0.0.8", - "@stdlib/string-repeat": "^0.0.9", - "@stdlib/utils-noop": "^0.0.14", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..a829f93 --- /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 78d0688..0000000 --- a/test/test.js +++ /dev/null @@ -1,328 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 whileAsync = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof whileAsync, 'function', 'main export is a function' ); - t.end(); -}); - -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() { - whileAsync( value, noop, 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() { - whileAsync( noop, value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a callback 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() { - whileAsync( noop, noop, value ); - }; - } -}); - -tape( 'while a test condition is true, the function invokes a provided function', function test( t ) { - var indices1 = [ 0, 1, 2, 3, 4, 5 ]; - var indices2 = [ 0, 1, 2, 3, 4 ]; - var j = -1; - var k = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices1[ j ], 'provides expected value' ); - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - k += 1; - t.strictEqual( i, indices2[ k ], 'provides expected value' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'while a test condition is true, the function invokes a provided function (always false)', function test( t ) { - var indices = [ 0 ]; - var j = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices[ j ], 'provides expected value' ); - clbk( null, false ); - } - - function fcn( i, next ) { - t.fail( 'should never be invoked' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx = { - 'count': 0 - }; - - whileAsync( predicate, fcn, done, ctx ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - this.count += 1; // eslint-disable-line no-invalid-this - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( ctx.count, 5, 'updates context' ); - t.end(); - } -}); - -tape( 'the function provides any results to a `done` callback', function test( t ) { - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, 'beep'+i, 'boop'+i, 'woot'+i ); - } - } - - function done( error, str1, str2, str3 ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( str1, 'beep4', 'returns expected value' ); - t.strictEqual( str2, 'boop4', 'returns expected value' ); - t.strictEqual( str3, 'woot4', 'returns expected value' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the predicate function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - if ( i === 1 ) { - return clbk( new Error( 'beep' ) ); - } - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 2, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the provided function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - if ( i === 2 ) { - return next( new Error( 'boop' ) ); - } - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 3, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'the function does not guarantee asynchronous execution', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - k = 1; - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - next(); - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( k, 0, 'releases the zalgo' ); - t.end(); - } -}); From bc8488a72e497d01822733eac11b300b0f0cd241 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 May 2023 01:40:57 +0000 Subject: [PATCH 047/143] 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 1dafc2a..c03bb93 100644 --- a/lib/main.js +++ b/lib/main.js @@ -21,7 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -62,13 +62,13 @@ function whileAsync( predicate, fcn, done, thisArg ) { var args; var idx; if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '0im3p', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0im2S', fcn ) ); } if ( !isFunction( done ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', done ) ); + throw new TypeError( format( '0im3Z', done ) ); } args = []; idx = 0; diff --git a/package.json b/package.json index 50a2ee9..fca61ba 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ }, "dependencies": { "@stdlib/assert-is-function": "^0.0.8", - "@stdlib/string-format": "^0.0.3" + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/bench": "^0.0.12", From 0e0c8e7c88390d8f1b5ecf125aae0c5dc0ca5f95 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 May 2023 03:41:46 +0000 Subject: [PATCH 048/143] Remove files --- index.d.ts | 127 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6309 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 b390f4c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,127 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Callback function. -*/ -type Nullary = () => void; - -/** -* Callback function. -* -* @param error - encountered error or null -*/ -type Unary = ( error: Error | null ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Binary = ( error: Error | null, bool: boolean ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Callback = Nullary | Unary | Binary; - -/** -* Callback invoked upon completion. -*/ -type DoneNullary = () => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -*/ -type DoneUnary = ( error: Error | null ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneBinary = ( error: Error | null, ...args: Array ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneCallback = DoneNullary | DoneUnary | DoneBinary; - -/** -* Checks whether an element in a collection passes a test. -* -* @param i - iteration number (starting from one) -* @param clbk - a callback indicating whether to invoke `fcn` -*/ -type Predicate = ( i: number, clbk: Callback ) => void; - -/** -* Invoked function. -* -* @param i - iteration number (starting from zero) -* @param next - a callback which must be invoked before proceeding to the next iteration -*/ -type Fcn = ( i: number, next: Function ) => void; - -/** -* Invokes a function while a test condition is true. -* -* @param predicate - function which indicates whether to continue invoking a function -* @param fcn - function to invoke -* @param done - callback to invoke upon completion -* @param thisArg - execution context for the invoked function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -declare function whileAsync( predicate: Predicate, fcn: Fcn, done: DoneCallback, thisArg?: any ): void; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = whileAsync; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d311722..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-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,e,i,o){var s,l;if(!r(n))throw new TypeError(t("0im3p",n));if(!r(e))throw new TypeError(t("0im2S",e));if(!r(i))throw new TypeError(t("0im3Z",i));function f(r,t){return r?i(r):t?e.call(o,l,m):(s.length&&s.unshift(null),void i.apply(null,s))}function m(r){var t;if(r)return i(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;uLA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index a829f93..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 5159f636ef755f907906a0ba105ae6fc9ab4150c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 May 2023 03:42:54 +0000 Subject: [PATCH 049/143] 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 | 105 - branches.md | 53 - docs/repl.txt | 72 - docs/types/test.ts | 83 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 57 - lib/main.js | 128 - package.json | 56 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 328 -- 37 files changed, 6202 insertions(+), 4032 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 (100%) 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 a85cd9b..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-05-01T01:10:17.181Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 0f8dec8..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/async/while) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 d8c823e..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/async/while) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 51569a6..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: '8 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@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 + + ```
@@ -279,7 +272,7 @@ whileAsync( predicate, fcn, done ); ## 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]. @@ -341,13 +334,13 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until +[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until/tree/esm -[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while +[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while/tree/esm -[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until +[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until/tree/esm -[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while +[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index ae9d749..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var whileAsync = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); - -bench( pkg+'::sync_predicate', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1e936a1..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/async/while" -%% click B href "https://github.com/stdlib-js/utils-async-while/tree/main" -%% click C href "https://github.com/stdlib-js/utils-async-while/tree/production" -%% click D href "https://github.com/stdlib-js/utils-async-while/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-async-while/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-async-while/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/async/while -[production-url]: https://github.com/stdlib-js/utils-async-while/tree/production -[deno-url]: https://github.com/stdlib-js/utils-async-while/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-async-while/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-async-while/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index d7ca8c9..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,72 +0,0 @@ - -{{alias}}( predicate, fcn, done[, thisArg] ) - Invokes a function while a test condition is true. - - The predicate function is provided two arguments: - - - `i`: iteration number (starting from zero) - - `clbk`: a callback indicating whether to invoke `fcn` - - The `clbk` function accepts two arguments: - - - `error`: error argument - - `bool`: test result - - If the test result is truthy, the function invokes `fcn`; otherwise, the - function invokes the `done` callback. - - The function to invoke is provided two arguments: - - - `i`: iteration number (starting from zero) - - `next`: a callback which must be invoked before proceeding to the next - iteration - - The first argument of the `next` callback is an `error` argument. If `fcn` - calls the `next` callback with a truthy `error` argument, the function - suspends execution and immediately calls the `done` callback for subsequent - `error` handling. - - The `done` callback is invoked with an `error` argument and any arguments - passed to the final `next` callback. - - Execution is *not* guaranteed to be asynchronous. To guarantee asynchrony, - wrap the `done` callback in a function which either executes at the end of - the current stack (e.g., `nextTick`) or during a subsequent turn of the - event loop (e.g., `setImmediate`, `setTimeout`). - - Parameters - ---------- - predicate: Function - The predicate function which indicates whether to continue invoking a - function. - - fcn: Function - The function to invoke. - - done: Function - Callback to invoke upon completion. - - thisArg: any (optional) - Execution context for the invoked function. - - Examples - -------- - > function predicate( i, clbk ) { clbk( null, i < 5 ); }; - > function fcn( i, next ) { - ... setTimeout( onTimeout, i ); - ... function onTimeout() { - ... next( null, 'boop'+i ); - ... } - ... }; - > function done( error, result ) { - ... if ( error ) { - ... throw error; - ... } - ... console.log( result ); - ... }; - > {{alias}}( predicate, fcn, done ) - boop: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4a543d9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,83 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 whileAsync = require( './index' ); - -const fcn = ( i: number, next: Function ): void => { - if ( i === void 0 ) { - throw new Error( '`i` is missing.' ); - } - next(); -}; - -const predicate = ( i: number, clbk: Function ): void => { - clbk( null, i < 5 ); -}; - -const done = ( error: Error | null ): void => { - if ( error ) { - throw error; - } -}; - - -// TESTS // - -// The function returns void... -{ - whileAsync( predicate, fcn, done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a predicate function... -{ - whileAsync( 2, fcn, done ); // $ExpectError - whileAsync( false, fcn, done ); // $ExpectError - whileAsync( true, fcn, done ); // $ExpectError - whileAsync( 'abc', fcn, done ); // $ExpectError - whileAsync( {}, fcn, done ); // $ExpectError - whileAsync( [], fcn, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function having a supported signature... -{ - whileAsync( predicate, 2, done ); // $ExpectError - whileAsync( predicate, false, done ); // $ExpectError - whileAsync( predicate, true, done ); // $ExpectError - whileAsync( predicate, 'abc', done ); // $ExpectError - whileAsync( predicate, {}, done ); // $ExpectError - whileAsync( predicate, [], done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a done callback argument which is not a function having a supported signature... -{ - whileAsync( predicate, fcn, 2 ); // $ExpectError - whileAsync( predicate, fcn, false ); // $ExpectError - whileAsync( predicate, fcn, true ); // $ExpectError - whileAsync( predicate, fcn, 'abc' ); // $ExpectError - whileAsync( predicate, fcn, {} ); // $ExpectError - whileAsync( predicate, fcn, [] ); // $ExpectError - whileAsync( predicate, fcn, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - whileAsync(); // $ExpectError - whileAsync( predicate ); // $ExpectError - whileAsync( predicate, fcn ); // $ExpectError - whileAsync( predicate, fcn, done, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a6af668..0000000 --- a/examples/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var repeatString = require( '@stdlib/string-repeat' ); -var whileAsync = require( './../lib' ); - -function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } -} - -function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, repeatString( 'beep', i+1 ) ); - } -} - -function done( error, result ) { - if ( error ) { - throw error; - } - console.log( result ); -} - -whileAsync( predicate, fcn, done ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..d311722 --- /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-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,e,i,o){var s,l;if(!r(n))throw new TypeError(t("0im3p",n));if(!r(e))throw new TypeError(t("0im2S",e));if(!r(i))throw new TypeError(t("0im3Z",i));function f(r,t){return r?i(r):t?e.call(o,l,m):(s.length&&s.unshift(null),void i.apply(null,s))}function m(r){var t;if(r)return i(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;uLA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a13bd4..0000000 --- a/lib/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Invoke a function while a test condition is true. -* -* @module @stdlib/utils-async-while -* -* @example -* var whileAsync = require( '@stdlib/utils-async-while' ); -* -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c03bb93..0000000 --- a/lib/main.js +++ /dev/null @@ -1,128 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Invokes a function while a test condition is true. -* -* @param {Function} predicate - function which indicates whether to continue invoking a function -* @param {Function} fcn - function to invoke -* @param {Callback} done - callback to invoke upon completion -* @param {*} [thisArg] - execution context for the invoked function -* @throws {TypeError} first argument must be a function -* @throws {TypeError} second argument must be a function -* @throws {TypeError} third argument must be a function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -function whileAsync( predicate, fcn, done, thisArg ) { - var args; - var idx; - if ( !isFunction( predicate ) ) { - throw new TypeError( format( '0im3p', predicate ) ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0im2S', fcn ) ); - } - if ( !isFunction( done ) ) { - throw new TypeError( format( '0im3Z', done ) ); - } - args = []; - idx = 0; - predicate( idx, onPredicate ); - - /** - * Callback invoked upon a predicate result. - * - * @private - * @param {(Error|null)} error - error object - * @param {boolean} result - predicate result - * @returns {void} - */ - function onPredicate( error, result ) { - if ( error ) { - return done( error ); - } - if ( result ) { - return fcn.call( thisArg, idx, next ); - } - if ( args.length ) { - args.unshift( null ); // error argument - } - done.apply( null, args ); - } - - /** - * Callback invoked upon completion of a provided function. - * - * @private - * @param {(Error|null)} error - error object - * @param {...*} results - function results - * @returns {void} - */ - function next( error ) { - var i; - if ( error ) { - return done( error ); - } - idx += 1; - - // Cache the most recent results... - if ( arguments.length > 1 ) { - args = new Array( arguments.length-1 ); - for ( i = 1; i < arguments.length; i++ ) { - args[ i-1 ] = arguments[ i ]; - } - } - // Run the test condition: - predicate( idx, onPredicate ); - } -} - - -// EXPORTS // - -module.exports = whileAsync; diff --git a/package.json b/package.json index fca61ba..0652b06 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Invoke a function while a test condition is true.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,35 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.0.8", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/bench": "^0.0.12", - "@stdlib/math-base-assert-is-nan": "^0.0.8", - "@stdlib/random-base-randu": "^0.0.8", - "@stdlib/string-repeat": "^0.0.9", - "@stdlib/utils-noop": "^0.0.14", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..970d757 --- /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 78d0688..0000000 --- a/test/test.js +++ /dev/null @@ -1,328 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 whileAsync = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof whileAsync, 'function', 'main export is a function' ); - t.end(); -}); - -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() { - whileAsync( value, noop, 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() { - whileAsync( noop, value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a callback 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() { - whileAsync( noop, noop, value ); - }; - } -}); - -tape( 'while a test condition is true, the function invokes a provided function', function test( t ) { - var indices1 = [ 0, 1, 2, 3, 4, 5 ]; - var indices2 = [ 0, 1, 2, 3, 4 ]; - var j = -1; - var k = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices1[ j ], 'provides expected value' ); - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - k += 1; - t.strictEqual( i, indices2[ k ], 'provides expected value' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'while a test condition is true, the function invokes a provided function (always false)', function test( t ) { - var indices = [ 0 ]; - var j = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices[ j ], 'provides expected value' ); - clbk( null, false ); - } - - function fcn( i, next ) { - t.fail( 'should never be invoked' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx = { - 'count': 0 - }; - - whileAsync( predicate, fcn, done, ctx ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - this.count += 1; // eslint-disable-line no-invalid-this - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( ctx.count, 5, 'updates context' ); - t.end(); - } -}); - -tape( 'the function provides any results to a `done` callback', function test( t ) { - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, 'beep'+i, 'boop'+i, 'woot'+i ); - } - } - - function done( error, str1, str2, str3 ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( str1, 'beep4', 'returns expected value' ); - t.strictEqual( str2, 'boop4', 'returns expected value' ); - t.strictEqual( str3, 'woot4', 'returns expected value' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the predicate function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - if ( i === 1 ) { - return clbk( new Error( 'beep' ) ); - } - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 2, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the provided function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - if ( i === 2 ) { - return next( new Error( 'boop' ) ); - } - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 3, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'the function does not guarantee asynchronous execution', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - k = 1; - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - next(); - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( k, 0, 'releases the zalgo' ); - t.end(); - } -}); From 4649de36ea55cf4b6fd231b3dd3235e1158b0693 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Jun 2023 01:43:36 +0000 Subject: [PATCH 050/143] 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 1dafc2a..c03bb93 100644 --- a/lib/main.js +++ b/lib/main.js @@ -21,7 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -62,13 +62,13 @@ function whileAsync( predicate, fcn, done, thisArg ) { var args; var idx; if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '0im3p', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0im2S', fcn ) ); } if ( !isFunction( done ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', done ) ); + throw new TypeError( format( '0im3Z', done ) ); } args = []; idx = 0; diff --git a/package.json b/package.json index 50a2ee9..fca61ba 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ }, "dependencies": { "@stdlib/assert-is-function": "^0.0.8", - "@stdlib/string-format": "^0.0.3" + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/bench": "^0.0.12", From c060791a9f4a44424e193c6a2003b8b0b58dc6c3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Jun 2023 03:50:33 +0000 Subject: [PATCH 051/143] Remove files --- index.d.ts | 127 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6309 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 b390f4c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,127 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Callback function. -*/ -type Nullary = () => void; - -/** -* Callback function. -* -* @param error - encountered error or null -*/ -type Unary = ( error: Error | null ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Binary = ( error: Error | null, bool: boolean ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Callback = Nullary | Unary | Binary; - -/** -* Callback invoked upon completion. -*/ -type DoneNullary = () => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -*/ -type DoneUnary = ( error: Error | null ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneBinary = ( error: Error | null, ...args: Array ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneCallback = DoneNullary | DoneUnary | DoneBinary; - -/** -* Checks whether an element in a collection passes a test. -* -* @param i - iteration number (starting from one) -* @param clbk - a callback indicating whether to invoke `fcn` -*/ -type Predicate = ( i: number, clbk: Callback ) => void; - -/** -* Invoked function. -* -* @param i - iteration number (starting from zero) -* @param next - a callback which must be invoked before proceeding to the next iteration -*/ -type Fcn = ( i: number, next: Function ) => void; - -/** -* Invokes a function while a test condition is true. -* -* @param predicate - function which indicates whether to continue invoking a function -* @param fcn - function to invoke -* @param done - callback to invoke upon completion -* @param thisArg - execution context for the invoked function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -declare function whileAsync( predicate: Predicate, fcn: Fcn, done: DoneCallback, thisArg?: any ): void; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = whileAsync; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d311722..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-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,e,i,o){var s,l;if(!r(n))throw new TypeError(t("0im3p",n));if(!r(e))throw new TypeError(t("0im2S",e));if(!r(i))throw new TypeError(t("0im3Z",i));function f(r,t){return r?i(r):t?e.call(o,l,m):(s.length&&s.unshift(null),void i.apply(null,s))}function m(r){var t;if(r)return i(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;uLA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 970d757..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 5f4d457792e72b46e9c6d08138c0a838d1cf6d00 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Jun 2023 03:51:30 +0000 Subject: [PATCH 052/143] 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 | 105 - branches.md | 53 - docs/repl.txt | 72 - docs/types/test.ts | 83 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 57 - lib/main.js | 128 - package.json | 56 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 328 -- 37 files changed, 6202 insertions(+), 4032 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 (100%) 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 ed50fc2..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-06-01T01:13:41.524Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 0f8dec8..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/async/while) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 d8c823e..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/async/while) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 51569a6..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: '8 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@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 + + ```
@@ -279,7 +272,7 @@ whileAsync( predicate, fcn, done ); ## 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]. @@ -341,13 +334,13 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until +[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until/tree/esm -[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while +[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while/tree/esm -[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until +[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until/tree/esm -[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while +[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index ae9d749..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var whileAsync = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); - -bench( pkg+'::sync_predicate', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1e936a1..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/async/while" -%% click B href "https://github.com/stdlib-js/utils-async-while/tree/main" -%% click C href "https://github.com/stdlib-js/utils-async-while/tree/production" -%% click D href "https://github.com/stdlib-js/utils-async-while/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-async-while/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-async-while/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/async/while -[production-url]: https://github.com/stdlib-js/utils-async-while/tree/production -[deno-url]: https://github.com/stdlib-js/utils-async-while/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-async-while/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-async-while/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index d7ca8c9..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,72 +0,0 @@ - -{{alias}}( predicate, fcn, done[, thisArg] ) - Invokes a function while a test condition is true. - - The predicate function is provided two arguments: - - - `i`: iteration number (starting from zero) - - `clbk`: a callback indicating whether to invoke `fcn` - - The `clbk` function accepts two arguments: - - - `error`: error argument - - `bool`: test result - - If the test result is truthy, the function invokes `fcn`; otherwise, the - function invokes the `done` callback. - - The function to invoke is provided two arguments: - - - `i`: iteration number (starting from zero) - - `next`: a callback which must be invoked before proceeding to the next - iteration - - The first argument of the `next` callback is an `error` argument. If `fcn` - calls the `next` callback with a truthy `error` argument, the function - suspends execution and immediately calls the `done` callback for subsequent - `error` handling. - - The `done` callback is invoked with an `error` argument and any arguments - passed to the final `next` callback. - - Execution is *not* guaranteed to be asynchronous. To guarantee asynchrony, - wrap the `done` callback in a function which either executes at the end of - the current stack (e.g., `nextTick`) or during a subsequent turn of the - event loop (e.g., `setImmediate`, `setTimeout`). - - Parameters - ---------- - predicate: Function - The predicate function which indicates whether to continue invoking a - function. - - fcn: Function - The function to invoke. - - done: Function - Callback to invoke upon completion. - - thisArg: any (optional) - Execution context for the invoked function. - - Examples - -------- - > function predicate( i, clbk ) { clbk( null, i < 5 ); }; - > function fcn( i, next ) { - ... setTimeout( onTimeout, i ); - ... function onTimeout() { - ... next( null, 'boop'+i ); - ... } - ... }; - > function done( error, result ) { - ... if ( error ) { - ... throw error; - ... } - ... console.log( result ); - ... }; - > {{alias}}( predicate, fcn, done ) - boop: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4a543d9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,83 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 whileAsync = require( './index' ); - -const fcn = ( i: number, next: Function ): void => { - if ( i === void 0 ) { - throw new Error( '`i` is missing.' ); - } - next(); -}; - -const predicate = ( i: number, clbk: Function ): void => { - clbk( null, i < 5 ); -}; - -const done = ( error: Error | null ): void => { - if ( error ) { - throw error; - } -}; - - -// TESTS // - -// The function returns void... -{ - whileAsync( predicate, fcn, done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a predicate function... -{ - whileAsync( 2, fcn, done ); // $ExpectError - whileAsync( false, fcn, done ); // $ExpectError - whileAsync( true, fcn, done ); // $ExpectError - whileAsync( 'abc', fcn, done ); // $ExpectError - whileAsync( {}, fcn, done ); // $ExpectError - whileAsync( [], fcn, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function having a supported signature... -{ - whileAsync( predicate, 2, done ); // $ExpectError - whileAsync( predicate, false, done ); // $ExpectError - whileAsync( predicate, true, done ); // $ExpectError - whileAsync( predicate, 'abc', done ); // $ExpectError - whileAsync( predicate, {}, done ); // $ExpectError - whileAsync( predicate, [], done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a done callback argument which is not a function having a supported signature... -{ - whileAsync( predicate, fcn, 2 ); // $ExpectError - whileAsync( predicate, fcn, false ); // $ExpectError - whileAsync( predicate, fcn, true ); // $ExpectError - whileAsync( predicate, fcn, 'abc' ); // $ExpectError - whileAsync( predicate, fcn, {} ); // $ExpectError - whileAsync( predicate, fcn, [] ); // $ExpectError - whileAsync( predicate, fcn, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - whileAsync(); // $ExpectError - whileAsync( predicate ); // $ExpectError - whileAsync( predicate, fcn ); // $ExpectError - whileAsync( predicate, fcn, done, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a6af668..0000000 --- a/examples/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var repeatString = require( '@stdlib/string-repeat' ); -var whileAsync = require( './../lib' ); - -function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } -} - -function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, repeatString( 'beep', i+1 ) ); - } -} - -function done( error, result ) { - if ( error ) { - throw error; - } - console.log( result ); -} - -whileAsync( predicate, fcn, done ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..d311722 --- /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-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,e,i,o){var s,l;if(!r(n))throw new TypeError(t("0im3p",n));if(!r(e))throw new TypeError(t("0im2S",e));if(!r(i))throw new TypeError(t("0im3Z",i));function f(r,t){return r?i(r):t?e.call(o,l,m):(s.length&&s.unshift(null),void i.apply(null,s))}function m(r){var t;if(r)return i(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;uLA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a13bd4..0000000 --- a/lib/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Invoke a function while a test condition is true. -* -* @module @stdlib/utils-async-while -* -* @example -* var whileAsync = require( '@stdlib/utils-async-while' ); -* -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c03bb93..0000000 --- a/lib/main.js +++ /dev/null @@ -1,128 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Invokes a function while a test condition is true. -* -* @param {Function} predicate - function which indicates whether to continue invoking a function -* @param {Function} fcn - function to invoke -* @param {Callback} done - callback to invoke upon completion -* @param {*} [thisArg] - execution context for the invoked function -* @throws {TypeError} first argument must be a function -* @throws {TypeError} second argument must be a function -* @throws {TypeError} third argument must be a function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -function whileAsync( predicate, fcn, done, thisArg ) { - var args; - var idx; - if ( !isFunction( predicate ) ) { - throw new TypeError( format( '0im3p', predicate ) ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0im2S', fcn ) ); - } - if ( !isFunction( done ) ) { - throw new TypeError( format( '0im3Z', done ) ); - } - args = []; - idx = 0; - predicate( idx, onPredicate ); - - /** - * Callback invoked upon a predicate result. - * - * @private - * @param {(Error|null)} error - error object - * @param {boolean} result - predicate result - * @returns {void} - */ - function onPredicate( error, result ) { - if ( error ) { - return done( error ); - } - if ( result ) { - return fcn.call( thisArg, idx, next ); - } - if ( args.length ) { - args.unshift( null ); // error argument - } - done.apply( null, args ); - } - - /** - * Callback invoked upon completion of a provided function. - * - * @private - * @param {(Error|null)} error - error object - * @param {...*} results - function results - * @returns {void} - */ - function next( error ) { - var i; - if ( error ) { - return done( error ); - } - idx += 1; - - // Cache the most recent results... - if ( arguments.length > 1 ) { - args = new Array( arguments.length-1 ); - for ( i = 1; i < arguments.length; i++ ) { - args[ i-1 ] = arguments[ i ]; - } - } - // Run the test condition: - predicate( idx, onPredicate ); - } -} - - -// EXPORTS // - -module.exports = whileAsync; diff --git a/package.json b/package.json index fca61ba..0652b06 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Invoke a function while a test condition is true.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,35 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.0.8", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/bench": "^0.0.12", - "@stdlib/math-base-assert-is-nan": "^0.0.8", - "@stdlib/random-base-randu": "^0.0.8", - "@stdlib/string-repeat": "^0.0.9", - "@stdlib/utils-noop": "^0.0.14", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..32633ae --- /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 78d0688..0000000 --- a/test/test.js +++ /dev/null @@ -1,328 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 whileAsync = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof whileAsync, 'function', 'main export is a function' ); - t.end(); -}); - -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() { - whileAsync( value, noop, 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() { - whileAsync( noop, value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a callback 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() { - whileAsync( noop, noop, value ); - }; - } -}); - -tape( 'while a test condition is true, the function invokes a provided function', function test( t ) { - var indices1 = [ 0, 1, 2, 3, 4, 5 ]; - var indices2 = [ 0, 1, 2, 3, 4 ]; - var j = -1; - var k = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices1[ j ], 'provides expected value' ); - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - k += 1; - t.strictEqual( i, indices2[ k ], 'provides expected value' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'while a test condition is true, the function invokes a provided function (always false)', function test( t ) { - var indices = [ 0 ]; - var j = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices[ j ], 'provides expected value' ); - clbk( null, false ); - } - - function fcn( i, next ) { - t.fail( 'should never be invoked' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx = { - 'count': 0 - }; - - whileAsync( predicate, fcn, done, ctx ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - this.count += 1; // eslint-disable-line no-invalid-this - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( ctx.count, 5, 'updates context' ); - t.end(); - } -}); - -tape( 'the function provides any results to a `done` callback', function test( t ) { - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, 'beep'+i, 'boop'+i, 'woot'+i ); - } - } - - function done( error, str1, str2, str3 ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( str1, 'beep4', 'returns expected value' ); - t.strictEqual( str2, 'boop4', 'returns expected value' ); - t.strictEqual( str3, 'woot4', 'returns expected value' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the predicate function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - if ( i === 1 ) { - return clbk( new Error( 'beep' ) ); - } - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 2, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the provided function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - if ( i === 2 ) { - return next( new Error( 'boop' ) ); - } - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 3, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'the function does not guarantee asynchronous execution', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - k = 1; - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - next(); - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( k, 0, 'releases the zalgo' ); - t.end(); - } -}); From 95e5a38674f9599c58945b685f97b3bd64ff91a3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jul 2023 01:44:20 +0000 Subject: [PATCH 053/143] 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 1dafc2a..c03bb93 100644 --- a/lib/main.js +++ b/lib/main.js @@ -21,7 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -62,13 +62,13 @@ function whileAsync( predicate, fcn, done, thisArg ) { var args; var idx; if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '0im3p', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0im2S', fcn ) ); } if ( !isFunction( done ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', done ) ); + throw new TypeError( format( '0im3Z', done ) ); } args = []; idx = 0; diff --git a/package.json b/package.json index 50a2ee9..fca61ba 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ }, "dependencies": { "@stdlib/assert-is-function": "^0.0.8", - "@stdlib/string-format": "^0.0.3" + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/bench": "^0.0.12", From 9f2c2b25bf334a722dcc0e9732dc2bedde902bc1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jul 2023 03:57:38 +0000 Subject: [PATCH 054/143] Remove files --- index.d.ts | 127 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6309 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 b390f4c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,127 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Callback function. -*/ -type Nullary = () => void; - -/** -* Callback function. -* -* @param error - encountered error or null -*/ -type Unary = ( error: Error | null ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Binary = ( error: Error | null, bool: boolean ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Callback = Nullary | Unary | Binary; - -/** -* Callback invoked upon completion. -*/ -type DoneNullary = () => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -*/ -type DoneUnary = ( error: Error | null ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneBinary = ( error: Error | null, ...args: Array ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneCallback = DoneNullary | DoneUnary | DoneBinary; - -/** -* Checks whether an element in a collection passes a test. -* -* @param i - iteration number (starting from one) -* @param clbk - a callback indicating whether to invoke `fcn` -*/ -type Predicate = ( i: number, clbk: Callback ) => void; - -/** -* Invoked function. -* -* @param i - iteration number (starting from zero) -* @param next - a callback which must be invoked before proceeding to the next iteration -*/ -type Fcn = ( i: number, next: Function ) => void; - -/** -* Invokes a function while a test condition is true. -* -* @param predicate - function which indicates whether to continue invoking a function -* @param fcn - function to invoke -* @param done - callback to invoke upon completion -* @param thisArg - execution context for the invoked function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -declare function whileAsync( predicate: Predicate, fcn: Fcn, done: DoneCallback, thisArg?: any ): void; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = whileAsync; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d311722..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-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,e,i,o){var s,l;if(!r(n))throw new TypeError(t("0im3p",n));if(!r(e))throw new TypeError(t("0im2S",e));if(!r(i))throw new TypeError(t("0im3Z",i));function f(r,t){return r?i(r):t?e.call(o,l,m):(s.length&&s.unshift(null),void i.apply(null,s))}function m(r){var t;if(r)return i(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;uLA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 32633ae..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From a1023efb4a4f9b376b55be196041c848fde5bb76 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jul 2023 03:58:36 +0000 Subject: [PATCH 055/143] 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 | 105 - branches.md | 53 - docs/repl.txt | 72 - docs/types/test.ts | 83 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 57 - lib/main.js | 128 - package.json | 56 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 328 -- 37 files changed, 6202 insertions(+), 4032 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 (100%) 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 1a0169a..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-07-01T01:13:56.061Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 0f8dec8..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/async/while) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 d8c823e..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/async/while) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 51569a6..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: '8 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@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 + + ```
@@ -279,7 +272,7 @@ whileAsync( predicate, fcn, done ); ## 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]. @@ -341,13 +334,13 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until +[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until/tree/esm -[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while +[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while/tree/esm -[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until +[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until/tree/esm -[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while +[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index ae9d749..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var whileAsync = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); - -bench( pkg+'::sync_predicate', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1e936a1..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/async/while" -%% click B href "https://github.com/stdlib-js/utils-async-while/tree/main" -%% click C href "https://github.com/stdlib-js/utils-async-while/tree/production" -%% click D href "https://github.com/stdlib-js/utils-async-while/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-async-while/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-async-while/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/async/while -[production-url]: https://github.com/stdlib-js/utils-async-while/tree/production -[deno-url]: https://github.com/stdlib-js/utils-async-while/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-async-while/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-async-while/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index d7ca8c9..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,72 +0,0 @@ - -{{alias}}( predicate, fcn, done[, thisArg] ) - Invokes a function while a test condition is true. - - The predicate function is provided two arguments: - - - `i`: iteration number (starting from zero) - - `clbk`: a callback indicating whether to invoke `fcn` - - The `clbk` function accepts two arguments: - - - `error`: error argument - - `bool`: test result - - If the test result is truthy, the function invokes `fcn`; otherwise, the - function invokes the `done` callback. - - The function to invoke is provided two arguments: - - - `i`: iteration number (starting from zero) - - `next`: a callback which must be invoked before proceeding to the next - iteration - - The first argument of the `next` callback is an `error` argument. If `fcn` - calls the `next` callback with a truthy `error` argument, the function - suspends execution and immediately calls the `done` callback for subsequent - `error` handling. - - The `done` callback is invoked with an `error` argument and any arguments - passed to the final `next` callback. - - Execution is *not* guaranteed to be asynchronous. To guarantee asynchrony, - wrap the `done` callback in a function which either executes at the end of - the current stack (e.g., `nextTick`) or during a subsequent turn of the - event loop (e.g., `setImmediate`, `setTimeout`). - - Parameters - ---------- - predicate: Function - The predicate function which indicates whether to continue invoking a - function. - - fcn: Function - The function to invoke. - - done: Function - Callback to invoke upon completion. - - thisArg: any (optional) - Execution context for the invoked function. - - Examples - -------- - > function predicate( i, clbk ) { clbk( null, i < 5 ); }; - > function fcn( i, next ) { - ... setTimeout( onTimeout, i ); - ... function onTimeout() { - ... next( null, 'boop'+i ); - ... } - ... }; - > function done( error, result ) { - ... if ( error ) { - ... throw error; - ... } - ... console.log( result ); - ... }; - > {{alias}}( predicate, fcn, done ) - boop: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4a543d9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,83 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 whileAsync = require( './index' ); - -const fcn = ( i: number, next: Function ): void => { - if ( i === void 0 ) { - throw new Error( '`i` is missing.' ); - } - next(); -}; - -const predicate = ( i: number, clbk: Function ): void => { - clbk( null, i < 5 ); -}; - -const done = ( error: Error | null ): void => { - if ( error ) { - throw error; - } -}; - - -// TESTS // - -// The function returns void... -{ - whileAsync( predicate, fcn, done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a predicate function... -{ - whileAsync( 2, fcn, done ); // $ExpectError - whileAsync( false, fcn, done ); // $ExpectError - whileAsync( true, fcn, done ); // $ExpectError - whileAsync( 'abc', fcn, done ); // $ExpectError - whileAsync( {}, fcn, done ); // $ExpectError - whileAsync( [], fcn, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function having a supported signature... -{ - whileAsync( predicate, 2, done ); // $ExpectError - whileAsync( predicate, false, done ); // $ExpectError - whileAsync( predicate, true, done ); // $ExpectError - whileAsync( predicate, 'abc', done ); // $ExpectError - whileAsync( predicate, {}, done ); // $ExpectError - whileAsync( predicate, [], done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a done callback argument which is not a function having a supported signature... -{ - whileAsync( predicate, fcn, 2 ); // $ExpectError - whileAsync( predicate, fcn, false ); // $ExpectError - whileAsync( predicate, fcn, true ); // $ExpectError - whileAsync( predicate, fcn, 'abc' ); // $ExpectError - whileAsync( predicate, fcn, {} ); // $ExpectError - whileAsync( predicate, fcn, [] ); // $ExpectError - whileAsync( predicate, fcn, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - whileAsync(); // $ExpectError - whileAsync( predicate ); // $ExpectError - whileAsync( predicate, fcn ); // $ExpectError - whileAsync( predicate, fcn, done, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a6af668..0000000 --- a/examples/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var repeatString = require( '@stdlib/string-repeat' ); -var whileAsync = require( './../lib' ); - -function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } -} - -function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, repeatString( 'beep', i+1 ) ); - } -} - -function done( error, result ) { - if ( error ) { - throw error; - } - console.log( result ); -} - -whileAsync( predicate, fcn, done ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..d311722 --- /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-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,e,i,o){var s,l;if(!r(n))throw new TypeError(t("0im3p",n));if(!r(e))throw new TypeError(t("0im2S",e));if(!r(i))throw new TypeError(t("0im3Z",i));function f(r,t){return r?i(r):t?e.call(o,l,m):(s.length&&s.unshift(null),void i.apply(null,s))}function m(r){var t;if(r)return i(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;uLA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a13bd4..0000000 --- a/lib/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Invoke a function while a test condition is true. -* -* @module @stdlib/utils-async-while -* -* @example -* var whileAsync = require( '@stdlib/utils-async-while' ); -* -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c03bb93..0000000 --- a/lib/main.js +++ /dev/null @@ -1,128 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Invokes a function while a test condition is true. -* -* @param {Function} predicate - function which indicates whether to continue invoking a function -* @param {Function} fcn - function to invoke -* @param {Callback} done - callback to invoke upon completion -* @param {*} [thisArg] - execution context for the invoked function -* @throws {TypeError} first argument must be a function -* @throws {TypeError} second argument must be a function -* @throws {TypeError} third argument must be a function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -function whileAsync( predicate, fcn, done, thisArg ) { - var args; - var idx; - if ( !isFunction( predicate ) ) { - throw new TypeError( format( '0im3p', predicate ) ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0im2S', fcn ) ); - } - if ( !isFunction( done ) ) { - throw new TypeError( format( '0im3Z', done ) ); - } - args = []; - idx = 0; - predicate( idx, onPredicate ); - - /** - * Callback invoked upon a predicate result. - * - * @private - * @param {(Error|null)} error - error object - * @param {boolean} result - predicate result - * @returns {void} - */ - function onPredicate( error, result ) { - if ( error ) { - return done( error ); - } - if ( result ) { - return fcn.call( thisArg, idx, next ); - } - if ( args.length ) { - args.unshift( null ); // error argument - } - done.apply( null, args ); - } - - /** - * Callback invoked upon completion of a provided function. - * - * @private - * @param {(Error|null)} error - error object - * @param {...*} results - function results - * @returns {void} - */ - function next( error ) { - var i; - if ( error ) { - return done( error ); - } - idx += 1; - - // Cache the most recent results... - if ( arguments.length > 1 ) { - args = new Array( arguments.length-1 ); - for ( i = 1; i < arguments.length; i++ ) { - args[ i-1 ] = arguments[ i ]; - } - } - // Run the test condition: - predicate( idx, onPredicate ); - } -} - - -// EXPORTS // - -module.exports = whileAsync; diff --git a/package.json b/package.json index fca61ba..0652b06 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Invoke a function while a test condition is true.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,35 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.0.8", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/bench": "^0.0.12", - "@stdlib/math-base-assert-is-nan": "^0.0.8", - "@stdlib/random-base-randu": "^0.0.8", - "@stdlib/string-repeat": "^0.0.9", - "@stdlib/utils-noop": "^0.0.14", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b407b9a --- /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 78d0688..0000000 --- a/test/test.js +++ /dev/null @@ -1,328 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 whileAsync = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof whileAsync, 'function', 'main export is a function' ); - t.end(); -}); - -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() { - whileAsync( value, noop, 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() { - whileAsync( noop, value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a callback 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() { - whileAsync( noop, noop, value ); - }; - } -}); - -tape( 'while a test condition is true, the function invokes a provided function', function test( t ) { - var indices1 = [ 0, 1, 2, 3, 4, 5 ]; - var indices2 = [ 0, 1, 2, 3, 4 ]; - var j = -1; - var k = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices1[ j ], 'provides expected value' ); - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - k += 1; - t.strictEqual( i, indices2[ k ], 'provides expected value' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'while a test condition is true, the function invokes a provided function (always false)', function test( t ) { - var indices = [ 0 ]; - var j = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices[ j ], 'provides expected value' ); - clbk( null, false ); - } - - function fcn( i, next ) { - t.fail( 'should never be invoked' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx = { - 'count': 0 - }; - - whileAsync( predicate, fcn, done, ctx ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - this.count += 1; // eslint-disable-line no-invalid-this - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( ctx.count, 5, 'updates context' ); - t.end(); - } -}); - -tape( 'the function provides any results to a `done` callback', function test( t ) { - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, 'beep'+i, 'boop'+i, 'woot'+i ); - } - } - - function done( error, str1, str2, str3 ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( str1, 'beep4', 'returns expected value' ); - t.strictEqual( str2, 'boop4', 'returns expected value' ); - t.strictEqual( str3, 'woot4', 'returns expected value' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the predicate function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - if ( i === 1 ) { - return clbk( new Error( 'beep' ) ); - } - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 2, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the provided function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - if ( i === 2 ) { - return next( new Error( 'boop' ) ); - } - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 3, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'the function does not guarantee asynchronous execution', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - k = 1; - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - next(); - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( k, 0, 'releases the zalgo' ); - t.end(); - } -}); From 168f08fc564192ff4682e65e7aa205a562362a0e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Aug 2023 01:46:43 +0000 Subject: [PATCH 056/143] 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 1dafc2a..c03bb93 100644 --- a/lib/main.js +++ b/lib/main.js @@ -21,7 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -62,13 +62,13 @@ function whileAsync( predicate, fcn, done, thisArg ) { var args; var idx; if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '0im3p', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0im2S', fcn ) ); } if ( !isFunction( done ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', done ) ); + throw new TypeError( format( '0im3Z', done ) ); } args = []; idx = 0; diff --git a/package.json b/package.json index 50a2ee9..fca61ba 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ }, "dependencies": { "@stdlib/assert-is-function": "^0.0.8", - "@stdlib/string-format": "^0.0.3" + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/bench": "^0.0.12", From a189dcbbea45171c72126e08d8952703707173d8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Aug 2023 04:14:01 +0000 Subject: [PATCH 057/143] Remove files --- index.d.ts | 127 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6309 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 b390f4c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,127 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Callback function. -*/ -type Nullary = () => void; - -/** -* Callback function. -* -* @param error - encountered error or null -*/ -type Unary = ( error: Error | null ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Binary = ( error: Error | null, bool: boolean ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Callback = Nullary | Unary | Binary; - -/** -* Callback invoked upon completion. -*/ -type DoneNullary = () => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -*/ -type DoneUnary = ( error: Error | null ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneBinary = ( error: Error | null, ...args: Array ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneCallback = DoneNullary | DoneUnary | DoneBinary; - -/** -* Checks whether an element in a collection passes a test. -* -* @param i - iteration number (starting from one) -* @param clbk - a callback indicating whether to invoke `fcn` -*/ -type Predicate = ( i: number, clbk: Callback ) => void; - -/** -* Invoked function. -* -* @param i - iteration number (starting from zero) -* @param next - a callback which must be invoked before proceeding to the next iteration -*/ -type Fcn = ( i: number, next: Function ) => void; - -/** -* Invokes a function while a test condition is true. -* -* @param predicate - function which indicates whether to continue invoking a function -* @param fcn - function to invoke -* @param done - callback to invoke upon completion -* @param thisArg - execution context for the invoked function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -declare function whileAsync( predicate: Predicate, fcn: Fcn, done: DoneCallback, thisArg?: any ): void; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = whileAsync; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d311722..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-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,e,i,o){var s,l;if(!r(n))throw new TypeError(t("0im3p",n));if(!r(e))throw new TypeError(t("0im2S",e));if(!r(i))throw new TypeError(t("0im3Z",i));function f(r,t){return r?i(r):t?e.call(o,l,m):(s.length&&s.unshift(null),void i.apply(null,s))}function m(r){var t;if(r)return i(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;uLA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b407b9a..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From f68fa340a40a9d4e61669f096e9ef136de292f21 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Aug 2023 04:14:48 +0000 Subject: [PATCH 058/143] 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 | 105 - branches.md | 53 - docs/repl.txt | 72 - docs/types/test.ts | 83 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 57 - lib/main.js | 128 - package.json | 56 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 328 -- 37 files changed, 6202 insertions(+), 4032 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 (100%) 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 3ff86d2..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-08-01T01:13:26.487Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 0f8dec8..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/async/while) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 d8c823e..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/async/while) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 51569a6..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: '8 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@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 + + ```
@@ -279,7 +272,7 @@ whileAsync( predicate, fcn, done ); ## 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]. @@ -341,13 +334,13 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until +[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until/tree/esm -[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while +[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while/tree/esm -[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until +[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until/tree/esm -[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while +[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index ae9d749..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var whileAsync = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); - -bench( pkg+'::sync_predicate', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1e936a1..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/async/while" -%% click B href "https://github.com/stdlib-js/utils-async-while/tree/main" -%% click C href "https://github.com/stdlib-js/utils-async-while/tree/production" -%% click D href "https://github.com/stdlib-js/utils-async-while/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-async-while/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-async-while/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/async/while -[production-url]: https://github.com/stdlib-js/utils-async-while/tree/production -[deno-url]: https://github.com/stdlib-js/utils-async-while/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-async-while/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-async-while/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index d7ca8c9..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,72 +0,0 @@ - -{{alias}}( predicate, fcn, done[, thisArg] ) - Invokes a function while a test condition is true. - - The predicate function is provided two arguments: - - - `i`: iteration number (starting from zero) - - `clbk`: a callback indicating whether to invoke `fcn` - - The `clbk` function accepts two arguments: - - - `error`: error argument - - `bool`: test result - - If the test result is truthy, the function invokes `fcn`; otherwise, the - function invokes the `done` callback. - - The function to invoke is provided two arguments: - - - `i`: iteration number (starting from zero) - - `next`: a callback which must be invoked before proceeding to the next - iteration - - The first argument of the `next` callback is an `error` argument. If `fcn` - calls the `next` callback with a truthy `error` argument, the function - suspends execution and immediately calls the `done` callback for subsequent - `error` handling. - - The `done` callback is invoked with an `error` argument and any arguments - passed to the final `next` callback. - - Execution is *not* guaranteed to be asynchronous. To guarantee asynchrony, - wrap the `done` callback in a function which either executes at the end of - the current stack (e.g., `nextTick`) or during a subsequent turn of the - event loop (e.g., `setImmediate`, `setTimeout`). - - Parameters - ---------- - predicate: Function - The predicate function which indicates whether to continue invoking a - function. - - fcn: Function - The function to invoke. - - done: Function - Callback to invoke upon completion. - - thisArg: any (optional) - Execution context for the invoked function. - - Examples - -------- - > function predicate( i, clbk ) { clbk( null, i < 5 ); }; - > function fcn( i, next ) { - ... setTimeout( onTimeout, i ); - ... function onTimeout() { - ... next( null, 'boop'+i ); - ... } - ... }; - > function done( error, result ) { - ... if ( error ) { - ... throw error; - ... } - ... console.log( result ); - ... }; - > {{alias}}( predicate, fcn, done ) - boop: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4a543d9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,83 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 whileAsync = require( './index' ); - -const fcn = ( i: number, next: Function ): void => { - if ( i === void 0 ) { - throw new Error( '`i` is missing.' ); - } - next(); -}; - -const predicate = ( i: number, clbk: Function ): void => { - clbk( null, i < 5 ); -}; - -const done = ( error: Error | null ): void => { - if ( error ) { - throw error; - } -}; - - -// TESTS // - -// The function returns void... -{ - whileAsync( predicate, fcn, done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a predicate function... -{ - whileAsync( 2, fcn, done ); // $ExpectError - whileAsync( false, fcn, done ); // $ExpectError - whileAsync( true, fcn, done ); // $ExpectError - whileAsync( 'abc', fcn, done ); // $ExpectError - whileAsync( {}, fcn, done ); // $ExpectError - whileAsync( [], fcn, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function having a supported signature... -{ - whileAsync( predicate, 2, done ); // $ExpectError - whileAsync( predicate, false, done ); // $ExpectError - whileAsync( predicate, true, done ); // $ExpectError - whileAsync( predicate, 'abc', done ); // $ExpectError - whileAsync( predicate, {}, done ); // $ExpectError - whileAsync( predicate, [], done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a done callback argument which is not a function having a supported signature... -{ - whileAsync( predicate, fcn, 2 ); // $ExpectError - whileAsync( predicate, fcn, false ); // $ExpectError - whileAsync( predicate, fcn, true ); // $ExpectError - whileAsync( predicate, fcn, 'abc' ); // $ExpectError - whileAsync( predicate, fcn, {} ); // $ExpectError - whileAsync( predicate, fcn, [] ); // $ExpectError - whileAsync( predicate, fcn, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - whileAsync(); // $ExpectError - whileAsync( predicate ); // $ExpectError - whileAsync( predicate, fcn ); // $ExpectError - whileAsync( predicate, fcn, done, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a6af668..0000000 --- a/examples/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var repeatString = require( '@stdlib/string-repeat' ); -var whileAsync = require( './../lib' ); - -function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } -} - -function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, repeatString( 'beep', i+1 ) ); - } -} - -function done( error, result ) { - if ( error ) { - throw error; - } - console.log( result ); -} - -whileAsync( predicate, fcn, done ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..d311722 --- /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-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,e,i,o){var s,l;if(!r(n))throw new TypeError(t("0im3p",n));if(!r(e))throw new TypeError(t("0im2S",e));if(!r(i))throw new TypeError(t("0im3Z",i));function f(r,t){return r?i(r):t?e.call(o,l,m):(s.length&&s.unshift(null),void i.apply(null,s))}function m(r){var t;if(r)return i(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;uLA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a13bd4..0000000 --- a/lib/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Invoke a function while a test condition is true. -* -* @module @stdlib/utils-async-while -* -* @example -* var whileAsync = require( '@stdlib/utils-async-while' ); -* -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c03bb93..0000000 --- a/lib/main.js +++ /dev/null @@ -1,128 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Invokes a function while a test condition is true. -* -* @param {Function} predicate - function which indicates whether to continue invoking a function -* @param {Function} fcn - function to invoke -* @param {Callback} done - callback to invoke upon completion -* @param {*} [thisArg] - execution context for the invoked function -* @throws {TypeError} first argument must be a function -* @throws {TypeError} second argument must be a function -* @throws {TypeError} third argument must be a function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -function whileAsync( predicate, fcn, done, thisArg ) { - var args; - var idx; - if ( !isFunction( predicate ) ) { - throw new TypeError( format( '0im3p', predicate ) ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0im2S', fcn ) ); - } - if ( !isFunction( done ) ) { - throw new TypeError( format( '0im3Z', done ) ); - } - args = []; - idx = 0; - predicate( idx, onPredicate ); - - /** - * Callback invoked upon a predicate result. - * - * @private - * @param {(Error|null)} error - error object - * @param {boolean} result - predicate result - * @returns {void} - */ - function onPredicate( error, result ) { - if ( error ) { - return done( error ); - } - if ( result ) { - return fcn.call( thisArg, idx, next ); - } - if ( args.length ) { - args.unshift( null ); // error argument - } - done.apply( null, args ); - } - - /** - * Callback invoked upon completion of a provided function. - * - * @private - * @param {(Error|null)} error - error object - * @param {...*} results - function results - * @returns {void} - */ - function next( error ) { - var i; - if ( error ) { - return done( error ); - } - idx += 1; - - // Cache the most recent results... - if ( arguments.length > 1 ) { - args = new Array( arguments.length-1 ); - for ( i = 1; i < arguments.length; i++ ) { - args[ i-1 ] = arguments[ i ]; - } - } - // Run the test condition: - predicate( idx, onPredicate ); - } -} - - -// EXPORTS // - -module.exports = whileAsync; diff --git a/package.json b/package.json index fca61ba..0652b06 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Invoke a function while a test condition is true.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,35 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.0.8", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/bench": "^0.0.12", - "@stdlib/math-base-assert-is-nan": "^0.0.8", - "@stdlib/random-base-randu": "^0.0.8", - "@stdlib/string-repeat": "^0.0.9", - "@stdlib/utils-noop": "^0.0.14", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..598cf8c --- /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 78d0688..0000000 --- a/test/test.js +++ /dev/null @@ -1,328 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 whileAsync = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof whileAsync, 'function', 'main export is a function' ); - t.end(); -}); - -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() { - whileAsync( value, noop, 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() { - whileAsync( noop, value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a callback 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() { - whileAsync( noop, noop, value ); - }; - } -}); - -tape( 'while a test condition is true, the function invokes a provided function', function test( t ) { - var indices1 = [ 0, 1, 2, 3, 4, 5 ]; - var indices2 = [ 0, 1, 2, 3, 4 ]; - var j = -1; - var k = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices1[ j ], 'provides expected value' ); - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - k += 1; - t.strictEqual( i, indices2[ k ], 'provides expected value' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'while a test condition is true, the function invokes a provided function (always false)', function test( t ) { - var indices = [ 0 ]; - var j = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices[ j ], 'provides expected value' ); - clbk( null, false ); - } - - function fcn( i, next ) { - t.fail( 'should never be invoked' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx = { - 'count': 0 - }; - - whileAsync( predicate, fcn, done, ctx ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - this.count += 1; // eslint-disable-line no-invalid-this - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( ctx.count, 5, 'updates context' ); - t.end(); - } -}); - -tape( 'the function provides any results to a `done` callback', function test( t ) { - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, 'beep'+i, 'boop'+i, 'woot'+i ); - } - } - - function done( error, str1, str2, str3 ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( str1, 'beep4', 'returns expected value' ); - t.strictEqual( str2, 'boop4', 'returns expected value' ); - t.strictEqual( str3, 'woot4', 'returns expected value' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the predicate function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - if ( i === 1 ) { - return clbk( new Error( 'beep' ) ); - } - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 2, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the provided function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - if ( i === 2 ) { - return next( new Error( 'boop' ) ); - } - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 3, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'the function does not guarantee asynchronous execution', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - k = 1; - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - next(); - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( k, 0, 'releases the zalgo' ); - t.end(); - } -}); From 7ce8f94a1c372c484f23f864fdae6e6a53198346 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 22 Sep 2023 21:15:26 +0000 Subject: [PATCH 059/143] 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 1dafc2a..2da009c 100644 --- a/lib/main.js +++ b/lib/main.js @@ -21,7 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -62,13 +62,13 @@ function whileAsync( predicate, fcn, done, thisArg ) { var args; var idx; if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '1Rr3c,J9', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '1Rr2H,G6', fcn ) ); } if ( !isFunction( done ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', done ) ); + throw new TypeError( format( '1Rr3N,G4', done ) ); } args = []; idx = 0; diff --git a/package.json b/package.json index 2c66789..e5588e0 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ }, "dependencies": { "@stdlib/assert-is-function": "^0.1.0", - "@stdlib/string-format": "^0.1.0" + "@stdlib/error-tools-fmtprodmsg": "^0.1.0" }, "devDependencies": { "@stdlib/bench": "^0.1.0", From e89784127fdb95b4025b61621752ec84f6f38fa7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 22 Sep 2023 21:33:05 +0000 Subject: [PATCH 060/143] Remove files --- index.d.ts | 127 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6309 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 b390f4c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,127 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Callback function. -*/ -type Nullary = () => void; - -/** -* Callback function. -* -* @param error - encountered error or null -*/ -type Unary = ( error: Error | null ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Binary = ( error: Error | null, bool: boolean ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Callback = Nullary | Unary | Binary; - -/** -* Callback invoked upon completion. -*/ -type DoneNullary = () => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -*/ -type DoneUnary = ( error: Error | null ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneBinary = ( error: Error | null, ...args: Array ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneCallback = DoneNullary | DoneUnary | DoneBinary; - -/** -* Checks whether an element in a collection passes a test. -* -* @param i - iteration number (starting from one) -* @param clbk - a callback indicating whether to invoke `fcn` -*/ -type Predicate = ( i: number, clbk: Callback ) => void; - -/** -* Invoked function. -* -* @param i - iteration number (starting from zero) -* @param next - a callback which must be invoked before proceeding to the next iteration -*/ -type Fcn = ( i: number, next: Function ) => void; - -/** -* Invokes a function while a test condition is true. -* -* @param predicate - function which indicates whether to continue invoking a function -* @param fcn - function to invoke -* @param done - callback to invoke upon completion -* @param thisArg - execution context for the invoked function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -declare function whileAsync( predicate: Predicate, fcn: Fcn, done: DoneCallback, thisArg?: any ): void; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = whileAsync; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d311722..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-function@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,e,i,o){var s,l;if(!r(n))throw new TypeError(t("0im3p",n));if(!r(e))throw new TypeError(t("0im2S",e));if(!r(i))throw new TypeError(t("0im3Z",i));function f(r,t){return r?i(r):t?e.call(o,l,m):(s.length&&s.unshift(null),void i.apply(null,s))}function m(r){var t;if(r)return i(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;uLA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 598cf8c..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 307f47a3f9f4e40f1a7972ea2f5c6bd05e86c54d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 22 Sep 2023 21:34:04 +0000 Subject: [PATCH 061/143] 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 | 105 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 72 - docs/types/test.ts | 83 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 57 - lib/main.js | 128 - package.json | 56 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 328 -- 40 files changed, 6202 insertions(+), 4066 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 (100%) 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 0f8dec8..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/async/while) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 d8c823e..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/async/while) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 51569a6..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: '8 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@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 + + ```
@@ -290,7 +283,7 @@ whileAsync( predicate, fcn, done ); ## 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]. @@ -352,13 +345,13 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until +[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until/tree/esm -[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while +[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while/tree/esm -[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until +[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until/tree/esm -[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while +[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index ae9d749..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var whileAsync = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); - -bench( pkg+'::sync_predicate', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1e936a1..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/async/while" -%% click B href "https://github.com/stdlib-js/utils-async-while/tree/main" -%% click C href "https://github.com/stdlib-js/utils-async-while/tree/production" -%% click D href "https://github.com/stdlib-js/utils-async-while/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-async-while/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-async-while/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/async/while -[production-url]: https://github.com/stdlib-js/utils-async-while/tree/production -[deno-url]: https://github.com/stdlib-js/utils-async-while/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-async-while/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-async-while/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 efdafdf..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import whileAsync from '../docs/types/index'; -export = whileAsync; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 159efee..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var v=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var m=v(function(p,g){ -var s=require('@stdlib/assert-is-function/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist');function c(t,r,e,o){var u,i;if(!s(t))throw new TypeError(l('1Rr3c',t));if(!s(r))throw new TypeError(l('1Rr2H',r));if(!s(e))throw new TypeError(l('1Rr3N',e));u=[],i=0,t(i,f);function f(a,n){if(a)return e(a);if(n)return r.call(o,i,h);u.length&&u.unshift(null),e.apply(null,u)}function h(a){var n;if(a)return e(a);if(i+=1,arguments.length>1)for(u=new Array(arguments.length-1),n=1;n 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = whileAsync;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Invoke a function while a test condition is true.\n*\n* @module @stdlib/utils-async-while\n*\n* @example\n* var whileAsync = require( '@stdlib/utils-async-while' );\n*\n* function predicate( i, clbk ) {\n* clbk( null, i < 5 );\n* }\n*\n* function fcn( i, next ) {\n* setTimeout( onTimeout, i );\n* function onTimeout() {\n* console.log( 'beep: %d', i );\n* next();\n* }\n* }\n*\n* function done( error ) {\n* if ( error ) {\n* throw error;\n* }\n* }\n*\n* whileAsync( predicate, fcn, done );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAS,QAAS,uBAAwB,EAqC9C,SAASC,EAAYC,EAAWC,EAAKC,EAAMC,EAAU,CACpD,IAAIC,EACAC,EACJ,GAAK,CAACR,EAAYG,CAAU,EAC3B,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAU,CAAE,EAE/G,GAAK,CAACH,EAAYI,CAAI,EACrB,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAI,CAAE,EAE1G,GAAK,CAACJ,EAAYK,CAAK,EACtB,MAAM,IAAI,UAAWJ,EAAQ,oEAAqEI,CAAK,CAAE,EAE1GE,EAAO,CAAC,EACRC,EAAM,EACNL,EAAWK,EAAKC,CAAY,EAU5B,SAASA,EAAaC,EAAOC,EAAS,CACrC,GAAKD,EACJ,OAAOL,EAAMK,CAAM,EAEpB,GAAKC,EACJ,OAAOP,EAAI,KAAME,EAASE,EAAKI,CAAK,EAEhCL,EAAK,QACTA,EAAK,QAAS,IAAK,EAEpBF,EAAK,MAAO,KAAME,CAAK,CACxB,CAUA,SAASK,EAAMF,EAAQ,CACtB,IAAIG,EACJ,GAAKH,EACJ,OAAOL,EAAMK,CAAM,EAKpB,GAHAF,GAAO,EAGF,UAAU,OAAS,EAEvB,IADAD,EAAO,IAAI,MAAO,UAAU,OAAO,CAAE,EAC/BM,EAAI,EAAGA,EAAI,UAAU,OAAQA,IAClCN,EAAMM,EAAE,CAAE,EAAI,UAAWA,CAAE,EAI7BV,EAAWK,EAAKC,CAAY,CAC7B,CACD,CAKAV,EAAO,QAAUG,IC5EjB,IAAIY,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "format", "whileAsync", "predicate", "fcn", "done", "thisArg", "args", "idx", "onPredicate", "error", "result", "next", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index d7ca8c9..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,72 +0,0 @@ - -{{alias}}( predicate, fcn, done[, thisArg] ) - Invokes a function while a test condition is true. - - The predicate function is provided two arguments: - - - `i`: iteration number (starting from zero) - - `clbk`: a callback indicating whether to invoke `fcn` - - The `clbk` function accepts two arguments: - - - `error`: error argument - - `bool`: test result - - If the test result is truthy, the function invokes `fcn`; otherwise, the - function invokes the `done` callback. - - The function to invoke is provided two arguments: - - - `i`: iteration number (starting from zero) - - `next`: a callback which must be invoked before proceeding to the next - iteration - - The first argument of the `next` callback is an `error` argument. If `fcn` - calls the `next` callback with a truthy `error` argument, the function - suspends execution and immediately calls the `done` callback for subsequent - `error` handling. - - The `done` callback is invoked with an `error` argument and any arguments - passed to the final `next` callback. - - Execution is *not* guaranteed to be asynchronous. To guarantee asynchrony, - wrap the `done` callback in a function which either executes at the end of - the current stack (e.g., `nextTick`) or during a subsequent turn of the - event loop (e.g., `setImmediate`, `setTimeout`). - - Parameters - ---------- - predicate: Function - The predicate function which indicates whether to continue invoking a - function. - - fcn: Function - The function to invoke. - - done: Function - Callback to invoke upon completion. - - thisArg: any (optional) - Execution context for the invoked function. - - Examples - -------- - > function predicate( i, clbk ) { clbk( null, i < 5 ); }; - > function fcn( i, next ) { - ... setTimeout( onTimeout, i ); - ... function onTimeout() { - ... next( null, 'boop'+i ); - ... } - ... }; - > function done( error, result ) { - ... if ( error ) { - ... throw error; - ... } - ... console.log( result ); - ... }; - > {{alias}}( predicate, fcn, done ) - boop: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4a543d9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,83 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 whileAsync = require( './index' ); - -const fcn = ( i: number, next: Function ): void => { - if ( i === void 0 ) { - throw new Error( '`i` is missing.' ); - } - next(); -}; - -const predicate = ( i: number, clbk: Function ): void => { - clbk( null, i < 5 ); -}; - -const done = ( error: Error | null ): void => { - if ( error ) { - throw error; - } -}; - - -// TESTS // - -// The function returns void... -{ - whileAsync( predicate, fcn, done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a predicate function... -{ - whileAsync( 2, fcn, done ); // $ExpectError - whileAsync( false, fcn, done ); // $ExpectError - whileAsync( true, fcn, done ); // $ExpectError - whileAsync( 'abc', fcn, done ); // $ExpectError - whileAsync( {}, fcn, done ); // $ExpectError - whileAsync( [], fcn, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function having a supported signature... -{ - whileAsync( predicate, 2, done ); // $ExpectError - whileAsync( predicate, false, done ); // $ExpectError - whileAsync( predicate, true, done ); // $ExpectError - whileAsync( predicate, 'abc', done ); // $ExpectError - whileAsync( predicate, {}, done ); // $ExpectError - whileAsync( predicate, [], done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a done callback argument which is not a function having a supported signature... -{ - whileAsync( predicate, fcn, 2 ); // $ExpectError - whileAsync( predicate, fcn, false ); // $ExpectError - whileAsync( predicate, fcn, true ); // $ExpectError - whileAsync( predicate, fcn, 'abc' ); // $ExpectError - whileAsync( predicate, fcn, {} ); // $ExpectError - whileAsync( predicate, fcn, [] ); // $ExpectError - whileAsync( predicate, fcn, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - whileAsync(); // $ExpectError - whileAsync( predicate ); // $ExpectError - whileAsync( predicate, fcn ); // $ExpectError - whileAsync( predicate, fcn, done, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a6af668..0000000 --- a/examples/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var repeatString = require( '@stdlib/string-repeat' ); -var whileAsync = require( './../lib' ); - -function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } -} - -function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, repeatString( 'beep', i+1 ) ); - } -} - -function done( error, result ) { - if ( error ) { - throw error; - } - console.log( result ); -} - -whileAsync( predicate, fcn, done ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..7cbe5fd --- /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-function@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.0-esm/index.mjs";function n(n,e,o,i){var s,l;if(!r(n))throw new TypeError(t("1Rr3c,J9",n));if(!r(e))throw new TypeError(t("1Rr2H,G6",e));if(!r(o))throw new TypeError(t("1Rr3N,G4",o));function f(r,t){return r?o(r):t?e.call(i,l,h):(s.length&&s.unshift(null),void o.apply(null,s))}function h(r){var t;if(r)return o(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;8LA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,WAAYR,IAE1C,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,WAAYP,IAE1C,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAc1C,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a13bd4..0000000 --- a/lib/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Invoke a function while a test condition is true. -* -* @module @stdlib/utils-async-while -* -* @example -* var whileAsync = require( '@stdlib/utils-async-while' ); -* -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 2da009c..0000000 --- a/lib/main.js +++ /dev/null @@ -1,128 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Invokes a function while a test condition is true. -* -* @param {Function} predicate - function which indicates whether to continue invoking a function -* @param {Function} fcn - function to invoke -* @param {Callback} done - callback to invoke upon completion -* @param {*} [thisArg] - execution context for the invoked function -* @throws {TypeError} first argument must be a function -* @throws {TypeError} second argument must be a function -* @throws {TypeError} third argument must be a function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -function whileAsync( predicate, fcn, done, thisArg ) { - var args; - var idx; - if ( !isFunction( predicate ) ) { - throw new TypeError( format( '1Rr3c,J9', predicate ) ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '1Rr2H,G6', fcn ) ); - } - if ( !isFunction( done ) ) { - throw new TypeError( format( '1Rr3N,G4', done ) ); - } - args = []; - idx = 0; - predicate( idx, onPredicate ); - - /** - * Callback invoked upon a predicate result. - * - * @private - * @param {(Error|null)} error - error object - * @param {boolean} result - predicate result - * @returns {void} - */ - function onPredicate( error, result ) { - if ( error ) { - return done( error ); - } - if ( result ) { - return fcn.call( thisArg, idx, next ); - } - if ( args.length ) { - args.unshift( null ); // error argument - } - done.apply( null, args ); - } - - /** - * Callback invoked upon completion of a provided function. - * - * @private - * @param {(Error|null)} error - error object - * @param {...*} results - function results - * @returns {void} - */ - function next( error ) { - var i; - if ( error ) { - return done( error ); - } - idx += 1; - - // Cache the most recent results... - if ( arguments.length > 1 ) { - args = new Array( arguments.length-1 ); - for ( i = 1; i < arguments.length; i++ ) { - args[ i-1 ] = arguments[ i ]; - } - } - // Run the test condition: - predicate( idx, onPredicate ); - } -} - - -// EXPORTS // - -module.exports = whileAsync; diff --git a/package.json b/package.json index e5588e0..6e9a1af 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Invoke a function while a test condition is true.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,35 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.0" - }, - "devDependencies": { - "@stdlib/bench": "^0.1.0", - "@stdlib/math-base-assert-is-nan": "^0.0.8", - "@stdlib/random-base-randu": "^0.0.8", - "@stdlib/string-repeat": "^0.0.9", - "@stdlib/utils-noop": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..5530d66 --- /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 78d0688..0000000 --- a/test/test.js +++ /dev/null @@ -1,328 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 whileAsync = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof whileAsync, 'function', 'main export is a function' ); - t.end(); -}); - -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() { - whileAsync( value, noop, 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() { - whileAsync( noop, value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a callback 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() { - whileAsync( noop, noop, value ); - }; - } -}); - -tape( 'while a test condition is true, the function invokes a provided function', function test( t ) { - var indices1 = [ 0, 1, 2, 3, 4, 5 ]; - var indices2 = [ 0, 1, 2, 3, 4 ]; - var j = -1; - var k = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices1[ j ], 'provides expected value' ); - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - k += 1; - t.strictEqual( i, indices2[ k ], 'provides expected value' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'while a test condition is true, the function invokes a provided function (always false)', function test( t ) { - var indices = [ 0 ]; - var j = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices[ j ], 'provides expected value' ); - clbk( null, false ); - } - - function fcn( i, next ) { - t.fail( 'should never be invoked' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx = { - 'count': 0 - }; - - whileAsync( predicate, fcn, done, ctx ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - this.count += 1; // eslint-disable-line no-invalid-this - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( ctx.count, 5, 'updates context' ); - t.end(); - } -}); - -tape( 'the function provides any results to a `done` callback', function test( t ) { - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, 'beep'+i, 'boop'+i, 'woot'+i ); - } - } - - function done( error, str1, str2, str3 ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( str1, 'beep4', 'returns expected value' ); - t.strictEqual( str2, 'boop4', 'returns expected value' ); - t.strictEqual( str3, 'woot4', 'returns expected value' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the predicate function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - if ( i === 1 ) { - return clbk( new Error( 'beep' ) ); - } - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 2, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the provided function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - if ( i === 2 ) { - return next( new Error( 'boop' ) ); - } - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 3, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'the function does not guarantee asynchronous execution', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - k = 1; - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - next(); - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( k, 0, 'releases the zalgo' ); - t.end(); - } -}); From 2bd4e6563d33cf9704a60917b651abe3565e28b4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 22 Sep 2023 21:44:47 +0000 Subject: [PATCH 062/143] 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 cda0fdc..17c50b8 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import whileAsync from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-async-while@esm/index.mjs'; +import whileAsync from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-async-while@v0.1.0-esm/index.mjs'; ``` #### whileAsync( predicate, fcn, done\[, thisArg ] ) @@ -215,7 +215,7 @@ function done( error ) { - - - - From 0664e153754ae0673e246f96c61d3cd4ad09698e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Oct 2023 15:51:40 +0000 Subject: [PATCH 066/143] 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 | 105 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 72 - docs/types/test.ts | 83 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 57 - lib/main.js | 128 - package.json | 56 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 328 -- test/test.js | 328 -- 42 files changed, 6202 insertions(+), 4453 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 (100%) 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 33d4d33..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-10-01T01:04:44.244Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 0f8dec8..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/async/while) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 9633c26..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/async/while) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 ee192db..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: '8 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' - # 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 + + ```
@@ -290,7 +283,7 @@ whileAsync( predicate, fcn, done ); ## 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]. @@ -352,13 +345,13 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until +[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until/tree/esm -[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while +[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while/tree/esm -[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until +[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until/tree/esm -[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while +[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index ae9d749..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var whileAsync = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); - -bench( pkg+'::sync_predicate', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1e936a1..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/async/while" -%% click B href "https://github.com/stdlib-js/utils-async-while/tree/main" -%% click C href "https://github.com/stdlib-js/utils-async-while/tree/production" -%% click D href "https://github.com/stdlib-js/utils-async-while/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-async-while/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-async-while/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/async/while -[production-url]: https://github.com/stdlib-js/utils-async-while/tree/production -[deno-url]: https://github.com/stdlib-js/utils-async-while/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-async-while/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-async-while/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 efdafdf..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import whileAsync from '../docs/types/index'; -export = whileAsync; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 159efee..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var v=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var m=v(function(p,g){ -var s=require('@stdlib/assert-is-function/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist');function c(t,r,e,o){var u,i;if(!s(t))throw new TypeError(l('1Rr3c',t));if(!s(r))throw new TypeError(l('1Rr2H',r));if(!s(e))throw new TypeError(l('1Rr3N',e));u=[],i=0,t(i,f);function f(a,n){if(a)return e(a);if(n)return r.call(o,i,h);u.length&&u.unshift(null),e.apply(null,u)}function h(a){var n;if(a)return e(a);if(i+=1,arguments.length>1)for(u=new Array(arguments.length-1),n=1;n 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = whileAsync;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Invoke a function while a test condition is true.\n*\n* @module @stdlib/utils-async-while\n*\n* @example\n* var whileAsync = require( '@stdlib/utils-async-while' );\n*\n* function predicate( i, clbk ) {\n* clbk( null, i < 5 );\n* }\n*\n* function fcn( i, next ) {\n* setTimeout( onTimeout, i );\n* function onTimeout() {\n* console.log( 'beep: %d', i );\n* next();\n* }\n* }\n*\n* function done( error ) {\n* if ( error ) {\n* throw error;\n* }\n* }\n*\n* whileAsync( predicate, fcn, done );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAS,QAAS,uBAAwB,EAqC9C,SAASC,EAAYC,EAAWC,EAAKC,EAAMC,EAAU,CACpD,IAAIC,EACAC,EACJ,GAAK,CAACR,EAAYG,CAAU,EAC3B,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAU,CAAE,EAE/G,GAAK,CAACH,EAAYI,CAAI,EACrB,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAI,CAAE,EAE1G,GAAK,CAACJ,EAAYK,CAAK,EACtB,MAAM,IAAI,UAAWJ,EAAQ,oEAAqEI,CAAK,CAAE,EAE1GE,EAAO,CAAC,EACRC,EAAM,EACNL,EAAWK,EAAKC,CAAY,EAU5B,SAASA,EAAaC,EAAOC,EAAS,CACrC,GAAKD,EACJ,OAAOL,EAAMK,CAAM,EAEpB,GAAKC,EACJ,OAAOP,EAAI,KAAME,EAASE,EAAKI,CAAK,EAEhCL,EAAK,QACTA,EAAK,QAAS,IAAK,EAEpBF,EAAK,MAAO,KAAME,CAAK,CACxB,CAUA,SAASK,EAAMF,EAAQ,CACtB,IAAIG,EACJ,GAAKH,EACJ,OAAOL,EAAMK,CAAM,EAKpB,GAHAF,GAAO,EAGF,UAAU,OAAS,EAEvB,IADAD,EAAO,IAAI,MAAO,UAAU,OAAO,CAAE,EAC/BM,EAAI,EAAGA,EAAI,UAAU,OAAQA,IAClCN,EAAMM,EAAE,CAAE,EAAI,UAAWA,CAAE,EAI7BV,EAAWK,EAAKC,CAAY,CAC7B,CACD,CAKAV,EAAO,QAAUG,IC5EjB,IAAIY,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "format", "whileAsync", "predicate", "fcn", "done", "thisArg", "args", "idx", "onPredicate", "error", "result", "next", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index d7ca8c9..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,72 +0,0 @@ - -{{alias}}( predicate, fcn, done[, thisArg] ) - Invokes a function while a test condition is true. - - The predicate function is provided two arguments: - - - `i`: iteration number (starting from zero) - - `clbk`: a callback indicating whether to invoke `fcn` - - The `clbk` function accepts two arguments: - - - `error`: error argument - - `bool`: test result - - If the test result is truthy, the function invokes `fcn`; otherwise, the - function invokes the `done` callback. - - The function to invoke is provided two arguments: - - - `i`: iteration number (starting from zero) - - `next`: a callback which must be invoked before proceeding to the next - iteration - - The first argument of the `next` callback is an `error` argument. If `fcn` - calls the `next` callback with a truthy `error` argument, the function - suspends execution and immediately calls the `done` callback for subsequent - `error` handling. - - The `done` callback is invoked with an `error` argument and any arguments - passed to the final `next` callback. - - Execution is *not* guaranteed to be asynchronous. To guarantee asynchrony, - wrap the `done` callback in a function which either executes at the end of - the current stack (e.g., `nextTick`) or during a subsequent turn of the - event loop (e.g., `setImmediate`, `setTimeout`). - - Parameters - ---------- - predicate: Function - The predicate function which indicates whether to continue invoking a - function. - - fcn: Function - The function to invoke. - - done: Function - Callback to invoke upon completion. - - thisArg: any (optional) - Execution context for the invoked function. - - Examples - -------- - > function predicate( i, clbk ) { clbk( null, i < 5 ); }; - > function fcn( i, next ) { - ... setTimeout( onTimeout, i ); - ... function onTimeout() { - ... next( null, 'boop'+i ); - ... } - ... }; - > function done( error, result ) { - ... if ( error ) { - ... throw error; - ... } - ... console.log( result ); - ... }; - > {{alias}}( predicate, fcn, done ) - boop: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4a543d9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,83 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 whileAsync = require( './index' ); - -const fcn = ( i: number, next: Function ): void => { - if ( i === void 0 ) { - throw new Error( '`i` is missing.' ); - } - next(); -}; - -const predicate = ( i: number, clbk: Function ): void => { - clbk( null, i < 5 ); -}; - -const done = ( error: Error | null ): void => { - if ( error ) { - throw error; - } -}; - - -// TESTS // - -// The function returns void... -{ - whileAsync( predicate, fcn, done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a predicate function... -{ - whileAsync( 2, fcn, done ); // $ExpectError - whileAsync( false, fcn, done ); // $ExpectError - whileAsync( true, fcn, done ); // $ExpectError - whileAsync( 'abc', fcn, done ); // $ExpectError - whileAsync( {}, fcn, done ); // $ExpectError - whileAsync( [], fcn, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function having a supported signature... -{ - whileAsync( predicate, 2, done ); // $ExpectError - whileAsync( predicate, false, done ); // $ExpectError - whileAsync( predicate, true, done ); // $ExpectError - whileAsync( predicate, 'abc', done ); // $ExpectError - whileAsync( predicate, {}, done ); // $ExpectError - whileAsync( predicate, [], done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a done callback argument which is not a function having a supported signature... -{ - whileAsync( predicate, fcn, 2 ); // $ExpectError - whileAsync( predicate, fcn, false ); // $ExpectError - whileAsync( predicate, fcn, true ); // $ExpectError - whileAsync( predicate, fcn, 'abc' ); // $ExpectError - whileAsync( predicate, fcn, {} ); // $ExpectError - whileAsync( predicate, fcn, [] ); // $ExpectError - whileAsync( predicate, fcn, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - whileAsync(); // $ExpectError - whileAsync( predicate ); // $ExpectError - whileAsync( predicate, fcn ); // $ExpectError - whileAsync( predicate, fcn, done, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a6af668..0000000 --- a/examples/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var repeatString = require( '@stdlib/string-repeat' ); -var whileAsync = require( './../lib' ); - -function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } -} - -function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, repeatString( 'beep', i+1 ) ); - } -} - -function done( error, result ) { - if ( error ) { - throw error; - } - console.log( result ); -} - -whileAsync( predicate, fcn, done ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..7cbe5fd --- /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-function@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.0-esm/index.mjs";function n(n,e,o,i){var s,l;if(!r(n))throw new TypeError(t("1Rr3c,J9",n));if(!r(e))throw new TypeError(t("1Rr2H,G6",e));if(!r(o))throw new TypeError(t("1Rr3N,G4",o));function f(r,t){return r?o(r):t?e.call(i,l,h):(s.length&&s.unshift(null),void o.apply(null,s))}function h(r){var t;if(r)return o(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;8LA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,WAAYR,IAE1C,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,WAAYP,IAE1C,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAc1C,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a13bd4..0000000 --- a/lib/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Invoke a function while a test condition is true. -* -* @module @stdlib/utils-async-while -* -* @example -* var whileAsync = require( '@stdlib/utils-async-while' ); -* -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 2da009c..0000000 --- a/lib/main.js +++ /dev/null @@ -1,128 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Invokes a function while a test condition is true. -* -* @param {Function} predicate - function which indicates whether to continue invoking a function -* @param {Function} fcn - function to invoke -* @param {Callback} done - callback to invoke upon completion -* @param {*} [thisArg] - execution context for the invoked function -* @throws {TypeError} first argument must be a function -* @throws {TypeError} second argument must be a function -* @throws {TypeError} third argument must be a function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -function whileAsync( predicate, fcn, done, thisArg ) { - var args; - var idx; - if ( !isFunction( predicate ) ) { - throw new TypeError( format( '1Rr3c,J9', predicate ) ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '1Rr2H,G6', fcn ) ); - } - if ( !isFunction( done ) ) { - throw new TypeError( format( '1Rr3N,G4', done ) ); - } - args = []; - idx = 0; - predicate( idx, onPredicate ); - - /** - * Callback invoked upon a predicate result. - * - * @private - * @param {(Error|null)} error - error object - * @param {boolean} result - predicate result - * @returns {void} - */ - function onPredicate( error, result ) { - if ( error ) { - return done( error ); - } - if ( result ) { - return fcn.call( thisArg, idx, next ); - } - if ( args.length ) { - args.unshift( null ); // error argument - } - done.apply( null, args ); - } - - /** - * Callback invoked upon completion of a provided function. - * - * @private - * @param {(Error|null)} error - error object - * @param {...*} results - function results - * @returns {void} - */ - function next( error ) { - var i; - if ( error ) { - return done( error ); - } - idx += 1; - - // Cache the most recent results... - if ( arguments.length > 1 ) { - args = new Array( arguments.length-1 ); - for ( i = 1; i < arguments.length; i++ ) { - args[ i-1 ] = arguments[ i ]; - } - } - // Run the test condition: - predicate( idx, onPredicate ); - } -} - - -// EXPORTS // - -module.exports = whileAsync; diff --git a/package.json b/package.json index dd2c605..6e9a1af 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Invoke a function while a test condition is true.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,35 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.0" - }, - "devDependencies": { - "@stdlib/bench": "^0.1.0", - "@stdlib/math-base-assert-is-nan": "^0.1.0", - "@stdlib/random-base-randu": "^0.1.0", - "@stdlib/string-repeat": "^0.1.0", - "@stdlib/utils-noop": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..4ab6ab1 --- /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 0952b56..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,328 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 whileAsync = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof whileAsync, 'function', 'main export is a function' ); - t.end(); -}); - -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() { - whileAsync( value, noop, 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() { - whileAsync( noop, value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a callback 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() { - whileAsync( noop, noop, value ); - }; - } -}); - -tape( 'while a test condition is true, the function invokes a provided function', function test( t ) { - var indices1 = [ 0, 1, 2, 3, 4, 5 ]; - var indices2 = [ 0, 1, 2, 3, 4 ]; - var j = -1; - var k = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices1[ j ], 'provides expected value' ); - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - k += 1; - t.strictEqual( i, indices2[ k ], 'provides expected value' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'while a test condition is true, the function invokes a provided function (always false)', function test( t ) { - var indices = [ 0 ]; - var j = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices[ j ], 'provides expected value' ); - clbk( null, false ); - } - - function fcn( i, next ) { - t.fail( 'should never be invoked' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx = { - 'count': 0 - }; - - whileAsync( predicate, fcn, done, ctx ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - this.count += 1; // eslint-disable-line no-invalid-this - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( ctx.count, 5, 'updates context' ); - t.end(); - } -}); - -tape( 'the function provides any results to a `done` callback', function test( t ) { - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, 'beep'+i, 'boop'+i, 'woot'+i ); - } - } - - function done( error, str1, str2, str3 ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( str1, 'beep4', 'returns expected value' ); - t.strictEqual( str2, 'boop4', 'returns expected value' ); - t.strictEqual( str3, 'woot4', 'returns expected value' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the predicate function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - if ( i === 1 ) { - return clbk( new Error( 'beep' ) ); - } - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 2, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the provided function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - if ( i === 2 ) { - return next( new Error( 'boop' ) ); - } - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 3, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'the function does not guarantee asynchronous execution', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - k = 1; - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - next(); - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( k, 0, 'releases the zalgo' ); - t.end(); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 78d0688..0000000 --- a/test/test.js +++ /dev/null @@ -1,328 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 whileAsync = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof whileAsync, 'function', 'main export is a function' ); - t.end(); -}); - -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() { - whileAsync( value, noop, 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() { - whileAsync( noop, value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a callback 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() { - whileAsync( noop, noop, value ); - }; - } -}); - -tape( 'while a test condition is true, the function invokes a provided function', function test( t ) { - var indices1 = [ 0, 1, 2, 3, 4, 5 ]; - var indices2 = [ 0, 1, 2, 3, 4 ]; - var j = -1; - var k = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices1[ j ], 'provides expected value' ); - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - k += 1; - t.strictEqual( i, indices2[ k ], 'provides expected value' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'while a test condition is true, the function invokes a provided function (always false)', function test( t ) { - var indices = [ 0 ]; - var j = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices[ j ], 'provides expected value' ); - clbk( null, false ); - } - - function fcn( i, next ) { - t.fail( 'should never be invoked' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx = { - 'count': 0 - }; - - whileAsync( predicate, fcn, done, ctx ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - this.count += 1; // eslint-disable-line no-invalid-this - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( ctx.count, 5, 'updates context' ); - t.end(); - } -}); - -tape( 'the function provides any results to a `done` callback', function test( t ) { - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, 'beep'+i, 'boop'+i, 'woot'+i ); - } - } - - function done( error, str1, str2, str3 ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( str1, 'beep4', 'returns expected value' ); - t.strictEqual( str2, 'boop4', 'returns expected value' ); - t.strictEqual( str3, 'woot4', 'returns expected value' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the predicate function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - if ( i === 1 ) { - return clbk( new Error( 'beep' ) ); - } - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 2, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the provided function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - if ( i === 2 ) { - return next( new Error( 'boop' ) ); - } - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 3, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'the function does not guarantee asynchronous execution', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - k = 1; - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - next(); - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( k, 0, 'releases the zalgo' ); - t.end(); - } -}); From e4e619a90f153c31e26a746b00ed04329c162e71 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 4 Oct 2023 01:10:42 +0000 Subject: [PATCH 067/143] 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 1dafc2a..2da009c 100644 --- a/lib/main.js +++ b/lib/main.js @@ -21,7 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -62,13 +62,13 @@ function whileAsync( predicate, fcn, done, thisArg ) { var args; var idx; if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '1Rr3c,J9', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '1Rr2H,G6', fcn ) ); } if ( !isFunction( done ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', done ) ); + throw new TypeError( format( '1Rr3N,G4', done ) ); } args = []; idx = 0; diff --git a/package.json b/package.json index 837bd98..f6ef4af 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ }, "dependencies": { "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/string-format": "^0.1.1" + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/bench": "^0.1.0", From c83ab2d8626877737a227336e50be101f2071ec7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 4 Oct 2023 09:53:29 +0000 Subject: [PATCH 068/143] Remove files --- index.d.ts | 127 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6309 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 09e781e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,127 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Callback function. -*/ -type Nullary = () => void; - -/** -* Callback function. -* -* @param error - encountered error or null -*/ -type Unary = ( error: Error | null ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Binary = ( error: Error | null, bool: boolean ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Callback = Nullary | Unary | Binary; - -/** -* Callback invoked upon completion. -*/ -type DoneNullary = () => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -*/ -type DoneUnary = ( error: Error | null ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneBinary = ( error: Error | null, ...args: Array ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneCallback = DoneNullary | DoneUnary | DoneBinary; - -/** -* Checks whether an element in a collection passes a test. -* -* @param i - iteration number (starting from one) -* @param clbk - a callback indicating whether to invoke `fcn` -*/ -type Predicate = ( i: number, clbk: Callback ) => void; - -/** -* Invoked function. -* -* @param i - iteration number (starting from zero) -* @param next - a callback which must be invoked before proceeding to the next iteration -*/ -type Fcn = ( i: number, next: Function ) => void; - -/** -* Invokes a function while a test condition is true. -* -* @param predicate - function which indicates whether to continue invoking a function -* @param fcn - function to invoke -* @param done - callback to invoke upon completion -* @param thisArg - execution context for the invoked function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -declare function whileAsync( predicate: Predicate, fcn: Fcn, done: DoneCallback, thisArg?: any ): void; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = whileAsync; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 7cbe5fd..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-function@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.0-esm/index.mjs";function n(n,e,o,i){var s,l;if(!r(n))throw new TypeError(t("1Rr3c,J9",n));if(!r(e))throw new TypeError(t("1Rr2H,G6",e));if(!r(o))throw new TypeError(t("1Rr3N,G4",o));function f(r,t){return r?o(r):t?e.call(i,l,h):(s.length&&s.unshift(null),void o.apply(null,s))}function h(r){var t;if(r)return o(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;8LA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,WAAYR,IAE1C,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,WAAYP,IAE1C,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAc1C,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 4ab6ab1..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 2e05ad02d378f586e05b0394b1dfdeeb80781053 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 4 Oct 2023 09:56:56 +0000 Subject: [PATCH 069/143] 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 | 105 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 72 - docs/types/test.ts | 83 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 57 - lib/main.js | 128 - package.json | 56 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 328 -- test/test.js | 328 -- 41 files changed, 6202 insertions(+), 4452 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 (100%) 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 0f8dec8..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/async/while) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 9633c26..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/async/while) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 ee192db..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: '8 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' - # 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 + + ```
@@ -290,7 +283,7 @@ whileAsync( predicate, fcn, done ); ## 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]. @@ -352,13 +345,13 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until +[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until/tree/esm -[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while +[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while/tree/esm -[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until +[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until/tree/esm -[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while +[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index ae9d749..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var whileAsync = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); - -bench( pkg+'::sync_predicate', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1e936a1..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/async/while" -%% click B href "https://github.com/stdlib-js/utils-async-while/tree/main" -%% click C href "https://github.com/stdlib-js/utils-async-while/tree/production" -%% click D href "https://github.com/stdlib-js/utils-async-while/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-async-while/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-async-while/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/async/while -[production-url]: https://github.com/stdlib-js/utils-async-while/tree/production -[deno-url]: https://github.com/stdlib-js/utils-async-while/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-async-while/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-async-while/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 efdafdf..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import whileAsync from '../docs/types/index'; -export = whileAsync; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 159efee..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var v=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var m=v(function(p,g){ -var s=require('@stdlib/assert-is-function/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist');function c(t,r,e,o){var u,i;if(!s(t))throw new TypeError(l('1Rr3c',t));if(!s(r))throw new TypeError(l('1Rr2H',r));if(!s(e))throw new TypeError(l('1Rr3N',e));u=[],i=0,t(i,f);function f(a,n){if(a)return e(a);if(n)return r.call(o,i,h);u.length&&u.unshift(null),e.apply(null,u)}function h(a){var n;if(a)return e(a);if(i+=1,arguments.length>1)for(u=new Array(arguments.length-1),n=1;n 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = whileAsync;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Invoke a function while a test condition is true.\n*\n* @module @stdlib/utils-async-while\n*\n* @example\n* var whileAsync = require( '@stdlib/utils-async-while' );\n*\n* function predicate( i, clbk ) {\n* clbk( null, i < 5 );\n* }\n*\n* function fcn( i, next ) {\n* setTimeout( onTimeout, i );\n* function onTimeout() {\n* console.log( 'beep: %d', i );\n* next();\n* }\n* }\n*\n* function done( error ) {\n* if ( error ) {\n* throw error;\n* }\n* }\n*\n* whileAsync( predicate, fcn, done );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAS,QAAS,uBAAwB,EAqC9C,SAASC,EAAYC,EAAWC,EAAKC,EAAMC,EAAU,CACpD,IAAIC,EACAC,EACJ,GAAK,CAACR,EAAYG,CAAU,EAC3B,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAU,CAAE,EAE/G,GAAK,CAACH,EAAYI,CAAI,EACrB,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAI,CAAE,EAE1G,GAAK,CAACJ,EAAYK,CAAK,EACtB,MAAM,IAAI,UAAWJ,EAAQ,oEAAqEI,CAAK,CAAE,EAE1GE,EAAO,CAAC,EACRC,EAAM,EACNL,EAAWK,EAAKC,CAAY,EAU5B,SAASA,EAAaC,EAAOC,EAAS,CACrC,GAAKD,EACJ,OAAOL,EAAMK,CAAM,EAEpB,GAAKC,EACJ,OAAOP,EAAI,KAAME,EAASE,EAAKI,CAAK,EAEhCL,EAAK,QACTA,EAAK,QAAS,IAAK,EAEpBF,EAAK,MAAO,KAAME,CAAK,CACxB,CAUA,SAASK,EAAMF,EAAQ,CACtB,IAAIG,EACJ,GAAKH,EACJ,OAAOL,EAAMK,CAAM,EAKpB,GAHAF,GAAO,EAGF,UAAU,OAAS,EAEvB,IADAD,EAAO,IAAI,MAAO,UAAU,OAAO,CAAE,EAC/BM,EAAI,EAAGA,EAAI,UAAU,OAAQA,IAClCN,EAAMM,EAAE,CAAE,EAAI,UAAWA,CAAE,EAI7BV,EAAWK,EAAKC,CAAY,CAC7B,CACD,CAKAV,EAAO,QAAUG,IC5EjB,IAAIY,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "format", "whileAsync", "predicate", "fcn", "done", "thisArg", "args", "idx", "onPredicate", "error", "result", "next", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index d7ca8c9..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,72 +0,0 @@ - -{{alias}}( predicate, fcn, done[, thisArg] ) - Invokes a function while a test condition is true. - - The predicate function is provided two arguments: - - - `i`: iteration number (starting from zero) - - `clbk`: a callback indicating whether to invoke `fcn` - - The `clbk` function accepts two arguments: - - - `error`: error argument - - `bool`: test result - - If the test result is truthy, the function invokes `fcn`; otherwise, the - function invokes the `done` callback. - - The function to invoke is provided two arguments: - - - `i`: iteration number (starting from zero) - - `next`: a callback which must be invoked before proceeding to the next - iteration - - The first argument of the `next` callback is an `error` argument. If `fcn` - calls the `next` callback with a truthy `error` argument, the function - suspends execution and immediately calls the `done` callback for subsequent - `error` handling. - - The `done` callback is invoked with an `error` argument and any arguments - passed to the final `next` callback. - - Execution is *not* guaranteed to be asynchronous. To guarantee asynchrony, - wrap the `done` callback in a function which either executes at the end of - the current stack (e.g., `nextTick`) or during a subsequent turn of the - event loop (e.g., `setImmediate`, `setTimeout`). - - Parameters - ---------- - predicate: Function - The predicate function which indicates whether to continue invoking a - function. - - fcn: Function - The function to invoke. - - done: Function - Callback to invoke upon completion. - - thisArg: any (optional) - Execution context for the invoked function. - - Examples - -------- - > function predicate( i, clbk ) { clbk( null, i < 5 ); }; - > function fcn( i, next ) { - ... setTimeout( onTimeout, i ); - ... function onTimeout() { - ... next( null, 'boop'+i ); - ... } - ... }; - > function done( error, result ) { - ... if ( error ) { - ... throw error; - ... } - ... console.log( result ); - ... }; - > {{alias}}( predicate, fcn, done ) - boop: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4a543d9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,83 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 whileAsync = require( './index' ); - -const fcn = ( i: number, next: Function ): void => { - if ( i === void 0 ) { - throw new Error( '`i` is missing.' ); - } - next(); -}; - -const predicate = ( i: number, clbk: Function ): void => { - clbk( null, i < 5 ); -}; - -const done = ( error: Error | null ): void => { - if ( error ) { - throw error; - } -}; - - -// TESTS // - -// The function returns void... -{ - whileAsync( predicate, fcn, done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a predicate function... -{ - whileAsync( 2, fcn, done ); // $ExpectError - whileAsync( false, fcn, done ); // $ExpectError - whileAsync( true, fcn, done ); // $ExpectError - whileAsync( 'abc', fcn, done ); // $ExpectError - whileAsync( {}, fcn, done ); // $ExpectError - whileAsync( [], fcn, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function having a supported signature... -{ - whileAsync( predicate, 2, done ); // $ExpectError - whileAsync( predicate, false, done ); // $ExpectError - whileAsync( predicate, true, done ); // $ExpectError - whileAsync( predicate, 'abc', done ); // $ExpectError - whileAsync( predicate, {}, done ); // $ExpectError - whileAsync( predicate, [], done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a done callback argument which is not a function having a supported signature... -{ - whileAsync( predicate, fcn, 2 ); // $ExpectError - whileAsync( predicate, fcn, false ); // $ExpectError - whileAsync( predicate, fcn, true ); // $ExpectError - whileAsync( predicate, fcn, 'abc' ); // $ExpectError - whileAsync( predicate, fcn, {} ); // $ExpectError - whileAsync( predicate, fcn, [] ); // $ExpectError - whileAsync( predicate, fcn, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - whileAsync(); // $ExpectError - whileAsync( predicate ); // $ExpectError - whileAsync( predicate, fcn ); // $ExpectError - whileAsync( predicate, fcn, done, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a6af668..0000000 --- a/examples/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var repeatString = require( '@stdlib/string-repeat' ); -var whileAsync = require( './../lib' ); - -function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } -} - -function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, repeatString( 'beep', i+1 ) ); - } -} - -function done( error, result ) { - if ( error ) { - throw error; - } - console.log( result ); -} - -whileAsync( predicate, fcn, done ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..7cbe5fd --- /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-function@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.0-esm/index.mjs";function n(n,e,o,i){var s,l;if(!r(n))throw new TypeError(t("1Rr3c,J9",n));if(!r(e))throw new TypeError(t("1Rr2H,G6",e));if(!r(o))throw new TypeError(t("1Rr3N,G4",o));function f(r,t){return r?o(r):t?e.call(i,l,h):(s.length&&s.unshift(null),void o.apply(null,s))}function h(r){var t;if(r)return o(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;8LA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,WAAYR,IAE1C,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,WAAYP,IAE1C,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAc1C,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a13bd4..0000000 --- a/lib/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Invoke a function while a test condition is true. -* -* @module @stdlib/utils-async-while -* -* @example -* var whileAsync = require( '@stdlib/utils-async-while' ); -* -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 2da009c..0000000 --- a/lib/main.js +++ /dev/null @@ -1,128 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Invokes a function while a test condition is true. -* -* @param {Function} predicate - function which indicates whether to continue invoking a function -* @param {Function} fcn - function to invoke -* @param {Callback} done - callback to invoke upon completion -* @param {*} [thisArg] - execution context for the invoked function -* @throws {TypeError} first argument must be a function -* @throws {TypeError} second argument must be a function -* @throws {TypeError} third argument must be a function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -function whileAsync( predicate, fcn, done, thisArg ) { - var args; - var idx; - if ( !isFunction( predicate ) ) { - throw new TypeError( format( '1Rr3c,J9', predicate ) ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '1Rr2H,G6', fcn ) ); - } - if ( !isFunction( done ) ) { - throw new TypeError( format( '1Rr3N,G4', done ) ); - } - args = []; - idx = 0; - predicate( idx, onPredicate ); - - /** - * Callback invoked upon a predicate result. - * - * @private - * @param {(Error|null)} error - error object - * @param {boolean} result - predicate result - * @returns {void} - */ - function onPredicate( error, result ) { - if ( error ) { - return done( error ); - } - if ( result ) { - return fcn.call( thisArg, idx, next ); - } - if ( args.length ) { - args.unshift( null ); // error argument - } - done.apply( null, args ); - } - - /** - * Callback invoked upon completion of a provided function. - * - * @private - * @param {(Error|null)} error - error object - * @param {...*} results - function results - * @returns {void} - */ - function next( error ) { - var i; - if ( error ) { - return done( error ); - } - idx += 1; - - // Cache the most recent results... - if ( arguments.length > 1 ) { - args = new Array( arguments.length-1 ); - for ( i = 1; i < arguments.length; i++ ) { - args[ i-1 ] = arguments[ i ]; - } - } - // Run the test condition: - predicate( idx, onPredicate ); - } -} - - -// EXPORTS // - -module.exports = whileAsync; diff --git a/package.json b/package.json index f6ef4af..751474c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Invoke a function while a test condition is true.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,35 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/bench": "^0.1.0", - "@stdlib/math-base-assert-is-nan": "^0.1.0", - "@stdlib/random-base-randu": "^0.1.0", - "@stdlib/string-repeat": "^0.1.0", - "@stdlib/utils-noop": "^0.1.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..cef8d7f --- /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 0952b56..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,328 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 whileAsync = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof whileAsync, 'function', 'main export is a function' ); - t.end(); -}); - -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() { - whileAsync( value, noop, 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() { - whileAsync( noop, value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a callback 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() { - whileAsync( noop, noop, value ); - }; - } -}); - -tape( 'while a test condition is true, the function invokes a provided function', function test( t ) { - var indices1 = [ 0, 1, 2, 3, 4, 5 ]; - var indices2 = [ 0, 1, 2, 3, 4 ]; - var j = -1; - var k = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices1[ j ], 'provides expected value' ); - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - k += 1; - t.strictEqual( i, indices2[ k ], 'provides expected value' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'while a test condition is true, the function invokes a provided function (always false)', function test( t ) { - var indices = [ 0 ]; - var j = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices[ j ], 'provides expected value' ); - clbk( null, false ); - } - - function fcn( i, next ) { - t.fail( 'should never be invoked' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx = { - 'count': 0 - }; - - whileAsync( predicate, fcn, done, ctx ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - this.count += 1; // eslint-disable-line no-invalid-this - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( ctx.count, 5, 'updates context' ); - t.end(); - } -}); - -tape( 'the function provides any results to a `done` callback', function test( t ) { - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, 'beep'+i, 'boop'+i, 'woot'+i ); - } - } - - function done( error, str1, str2, str3 ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( str1, 'beep4', 'returns expected value' ); - t.strictEqual( str2, 'boop4', 'returns expected value' ); - t.strictEqual( str3, 'woot4', 'returns expected value' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the predicate function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - if ( i === 1 ) { - return clbk( new Error( 'beep' ) ); - } - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 2, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the provided function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - if ( i === 2 ) { - return next( new Error( 'boop' ) ); - } - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 3, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'the function does not guarantee asynchronous execution', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - k = 1; - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - next(); - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( k, 0, 'releases the zalgo' ); - t.end(); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 78d0688..0000000 --- a/test/test.js +++ /dev/null @@ -1,328 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 whileAsync = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof whileAsync, 'function', 'main export is a function' ); - t.end(); -}); - -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() { - whileAsync( value, noop, 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() { - whileAsync( noop, value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a callback 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() { - whileAsync( noop, noop, value ); - }; - } -}); - -tape( 'while a test condition is true, the function invokes a provided function', function test( t ) { - var indices1 = [ 0, 1, 2, 3, 4, 5 ]; - var indices2 = [ 0, 1, 2, 3, 4 ]; - var j = -1; - var k = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices1[ j ], 'provides expected value' ); - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - k += 1; - t.strictEqual( i, indices2[ k ], 'provides expected value' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'while a test condition is true, the function invokes a provided function (always false)', function test( t ) { - var indices = [ 0 ]; - var j = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices[ j ], 'provides expected value' ); - clbk( null, false ); - } - - function fcn( i, next ) { - t.fail( 'should never be invoked' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx = { - 'count': 0 - }; - - whileAsync( predicate, fcn, done, ctx ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - this.count += 1; // eslint-disable-line no-invalid-this - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( ctx.count, 5, 'updates context' ); - t.end(); - } -}); - -tape( 'the function provides any results to a `done` callback', function test( t ) { - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, 'beep'+i, 'boop'+i, 'woot'+i ); - } - } - - function done( error, str1, str2, str3 ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( str1, 'beep4', 'returns expected value' ); - t.strictEqual( str2, 'boop4', 'returns expected value' ); - t.strictEqual( str3, 'woot4', 'returns expected value' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the predicate function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - if ( i === 1 ) { - return clbk( new Error( 'beep' ) ); - } - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 2, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the provided function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - if ( i === 2 ) { - return next( new Error( 'boop' ) ); - } - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 3, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'the function does not guarantee asynchronous execution', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - k = 1; - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - next(); - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( k, 0, 'releases the zalgo' ); - t.end(); - } -}); From 293815da4f970c1ba27fc04a5327d819104e30cc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 4 Oct 2023 15:24:13 +0000 Subject: [PATCH 070/143] Update README.md for ESM bundle v0.1.1 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b9e3098..3ae7456 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import whileAsync from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-async-while@esm/index.mjs'; +import whileAsync from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-async-while@v0.1.1-esm/index.mjs'; ``` #### whileAsync( predicate, fcn, done\[, thisArg ] ) @@ -215,7 +215,7 @@ function done( error ) { - - - - From 3544ca0000fdd90c431d1d1a1ee6fa3dee907720 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 5 Oct 2023 18:04:57 +0000 Subject: [PATCH 074/143] 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 | 105 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 72 - docs/types/test.ts | 83 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 57 - lib/main.js | 128 - package.json | 56 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 328 -- test/test.js | 328 -- 41 files changed, 6202 insertions(+), 4452 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 (100%) 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 0f8dec8..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/async/while) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 9633c26..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/async/while) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 ee192db..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: '8 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' - # 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 + + ```
@@ -290,7 +283,7 @@ whileAsync( predicate, fcn, done ); ## 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]. @@ -352,13 +345,13 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until +[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until/tree/esm -[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while +[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while/tree/esm -[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until +[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until/tree/esm -[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while +[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index ae9d749..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var whileAsync = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); - -bench( pkg+'::sync_predicate', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1e936a1..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/async/while" -%% click B href "https://github.com/stdlib-js/utils-async-while/tree/main" -%% click C href "https://github.com/stdlib-js/utils-async-while/tree/production" -%% click D href "https://github.com/stdlib-js/utils-async-while/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-async-while/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-async-while/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/async/while -[production-url]: https://github.com/stdlib-js/utils-async-while/tree/production -[deno-url]: https://github.com/stdlib-js/utils-async-while/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-async-while/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-async-while/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 efdafdf..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import whileAsync from '../docs/types/index'; -export = whileAsync; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 159efee..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var v=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var m=v(function(p,g){ -var s=require('@stdlib/assert-is-function/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist');function c(t,r,e,o){var u,i;if(!s(t))throw new TypeError(l('1Rr3c',t));if(!s(r))throw new TypeError(l('1Rr2H',r));if(!s(e))throw new TypeError(l('1Rr3N',e));u=[],i=0,t(i,f);function f(a,n){if(a)return e(a);if(n)return r.call(o,i,h);u.length&&u.unshift(null),e.apply(null,u)}function h(a){var n;if(a)return e(a);if(i+=1,arguments.length>1)for(u=new Array(arguments.length-1),n=1;n 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = whileAsync;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Invoke a function while a test condition is true.\n*\n* @module @stdlib/utils-async-while\n*\n* @example\n* var whileAsync = require( '@stdlib/utils-async-while' );\n*\n* function predicate( i, clbk ) {\n* clbk( null, i < 5 );\n* }\n*\n* function fcn( i, next ) {\n* setTimeout( onTimeout, i );\n* function onTimeout() {\n* console.log( 'beep: %d', i );\n* next();\n* }\n* }\n*\n* function done( error ) {\n* if ( error ) {\n* throw error;\n* }\n* }\n*\n* whileAsync( predicate, fcn, done );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAS,QAAS,uBAAwB,EAqC9C,SAASC,EAAYC,EAAWC,EAAKC,EAAMC,EAAU,CACpD,IAAIC,EACAC,EACJ,GAAK,CAACR,EAAYG,CAAU,EAC3B,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAU,CAAE,EAE/G,GAAK,CAACH,EAAYI,CAAI,EACrB,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAI,CAAE,EAE1G,GAAK,CAACJ,EAAYK,CAAK,EACtB,MAAM,IAAI,UAAWJ,EAAQ,oEAAqEI,CAAK,CAAE,EAE1GE,EAAO,CAAC,EACRC,EAAM,EACNL,EAAWK,EAAKC,CAAY,EAU5B,SAASA,EAAaC,EAAOC,EAAS,CACrC,GAAKD,EACJ,OAAOL,EAAMK,CAAM,EAEpB,GAAKC,EACJ,OAAOP,EAAI,KAAME,EAASE,EAAKI,CAAK,EAEhCL,EAAK,QACTA,EAAK,QAAS,IAAK,EAEpBF,EAAK,MAAO,KAAME,CAAK,CACxB,CAUA,SAASK,EAAMF,EAAQ,CACtB,IAAIG,EACJ,GAAKH,EACJ,OAAOL,EAAMK,CAAM,EAKpB,GAHAF,GAAO,EAGF,UAAU,OAAS,EAEvB,IADAD,EAAO,IAAI,MAAO,UAAU,OAAO,CAAE,EAC/BM,EAAI,EAAGA,EAAI,UAAU,OAAQA,IAClCN,EAAMM,EAAE,CAAE,EAAI,UAAWA,CAAE,EAI7BV,EAAWK,EAAKC,CAAY,CAC7B,CACD,CAKAV,EAAO,QAAUG,IC5EjB,IAAIY,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "format", "whileAsync", "predicate", "fcn", "done", "thisArg", "args", "idx", "onPredicate", "error", "result", "next", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index d7ca8c9..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,72 +0,0 @@ - -{{alias}}( predicate, fcn, done[, thisArg] ) - Invokes a function while a test condition is true. - - The predicate function is provided two arguments: - - - `i`: iteration number (starting from zero) - - `clbk`: a callback indicating whether to invoke `fcn` - - The `clbk` function accepts two arguments: - - - `error`: error argument - - `bool`: test result - - If the test result is truthy, the function invokes `fcn`; otherwise, the - function invokes the `done` callback. - - The function to invoke is provided two arguments: - - - `i`: iteration number (starting from zero) - - `next`: a callback which must be invoked before proceeding to the next - iteration - - The first argument of the `next` callback is an `error` argument. If `fcn` - calls the `next` callback with a truthy `error` argument, the function - suspends execution and immediately calls the `done` callback for subsequent - `error` handling. - - The `done` callback is invoked with an `error` argument and any arguments - passed to the final `next` callback. - - Execution is *not* guaranteed to be asynchronous. To guarantee asynchrony, - wrap the `done` callback in a function which either executes at the end of - the current stack (e.g., `nextTick`) or during a subsequent turn of the - event loop (e.g., `setImmediate`, `setTimeout`). - - Parameters - ---------- - predicate: Function - The predicate function which indicates whether to continue invoking a - function. - - fcn: Function - The function to invoke. - - done: Function - Callback to invoke upon completion. - - thisArg: any (optional) - Execution context for the invoked function. - - Examples - -------- - > function predicate( i, clbk ) { clbk( null, i < 5 ); }; - > function fcn( i, next ) { - ... setTimeout( onTimeout, i ); - ... function onTimeout() { - ... next( null, 'boop'+i ); - ... } - ... }; - > function done( error, result ) { - ... if ( error ) { - ... throw error; - ... } - ... console.log( result ); - ... }; - > {{alias}}( predicate, fcn, done ) - boop: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4a543d9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,83 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 whileAsync = require( './index' ); - -const fcn = ( i: number, next: Function ): void => { - if ( i === void 0 ) { - throw new Error( '`i` is missing.' ); - } - next(); -}; - -const predicate = ( i: number, clbk: Function ): void => { - clbk( null, i < 5 ); -}; - -const done = ( error: Error | null ): void => { - if ( error ) { - throw error; - } -}; - - -// TESTS // - -// The function returns void... -{ - whileAsync( predicate, fcn, done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a predicate function... -{ - whileAsync( 2, fcn, done ); // $ExpectError - whileAsync( false, fcn, done ); // $ExpectError - whileAsync( true, fcn, done ); // $ExpectError - whileAsync( 'abc', fcn, done ); // $ExpectError - whileAsync( {}, fcn, done ); // $ExpectError - whileAsync( [], fcn, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function having a supported signature... -{ - whileAsync( predicate, 2, done ); // $ExpectError - whileAsync( predicate, false, done ); // $ExpectError - whileAsync( predicate, true, done ); // $ExpectError - whileAsync( predicate, 'abc', done ); // $ExpectError - whileAsync( predicate, {}, done ); // $ExpectError - whileAsync( predicate, [], done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a done callback argument which is not a function having a supported signature... -{ - whileAsync( predicate, fcn, 2 ); // $ExpectError - whileAsync( predicate, fcn, false ); // $ExpectError - whileAsync( predicate, fcn, true ); // $ExpectError - whileAsync( predicate, fcn, 'abc' ); // $ExpectError - whileAsync( predicate, fcn, {} ); // $ExpectError - whileAsync( predicate, fcn, [] ); // $ExpectError - whileAsync( predicate, fcn, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - whileAsync(); // $ExpectError - whileAsync( predicate ); // $ExpectError - whileAsync( predicate, fcn ); // $ExpectError - whileAsync( predicate, fcn, done, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a6af668..0000000 --- a/examples/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var repeatString = require( '@stdlib/string-repeat' ); -var whileAsync = require( './../lib' ); - -function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } -} - -function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, repeatString( 'beep', i+1 ) ); - } -} - -function done( error, result ) { - if ( error ) { - throw error; - } - console.log( result ); -} - -whileAsync( predicate, fcn, done ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..32e669e --- /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-function@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";function n(n,e,o,i){var s,l;if(!r(n))throw new TypeError(t("1Rr3c,J9",n));if(!r(e))throw new TypeError(t("1Rr2H,G6",e));if(!r(o))throw new TypeError(t("1Rr3N,G4",o));function f(r,t){return r?o(r):t?e.call(i,l,h):(s.length&&s.unshift(null),void o.apply(null,s))}function h(r){var t;if(r)return o(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;8LA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,WAAYR,IAE1C,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,WAAYP,IAE1C,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAc1C,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a13bd4..0000000 --- a/lib/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Invoke a function while a test condition is true. -* -* @module @stdlib/utils-async-while -* -* @example -* var whileAsync = require( '@stdlib/utils-async-while' ); -* -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 2da009c..0000000 --- a/lib/main.js +++ /dev/null @@ -1,128 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Invokes a function while a test condition is true. -* -* @param {Function} predicate - function which indicates whether to continue invoking a function -* @param {Function} fcn - function to invoke -* @param {Callback} done - callback to invoke upon completion -* @param {*} [thisArg] - execution context for the invoked function -* @throws {TypeError} first argument must be a function -* @throws {TypeError} second argument must be a function -* @throws {TypeError} third argument must be a function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -function whileAsync( predicate, fcn, done, thisArg ) { - var args; - var idx; - if ( !isFunction( predicate ) ) { - throw new TypeError( format( '1Rr3c,J9', predicate ) ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '1Rr2H,G6', fcn ) ); - } - if ( !isFunction( done ) ) { - throw new TypeError( format( '1Rr3N,G4', done ) ); - } - args = []; - idx = 0; - predicate( idx, onPredicate ); - - /** - * Callback invoked upon a predicate result. - * - * @private - * @param {(Error|null)} error - error object - * @param {boolean} result - predicate result - * @returns {void} - */ - function onPredicate( error, result ) { - if ( error ) { - return done( error ); - } - if ( result ) { - return fcn.call( thisArg, idx, next ); - } - if ( args.length ) { - args.unshift( null ); // error argument - } - done.apply( null, args ); - } - - /** - * Callback invoked upon completion of a provided function. - * - * @private - * @param {(Error|null)} error - error object - * @param {...*} results - function results - * @returns {void} - */ - function next( error ) { - var i; - if ( error ) { - return done( error ); - } - idx += 1; - - // Cache the most recent results... - if ( arguments.length > 1 ) { - args = new Array( arguments.length-1 ); - for ( i = 1; i < arguments.length; i++ ) { - args[ i-1 ] = arguments[ i ]; - } - } - // Run the test condition: - predicate( idx, onPredicate ); - } -} - - -// EXPORTS // - -module.exports = whileAsync; diff --git a/package.json b/package.json index 2167257..751474c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Invoke a function while a test condition is true.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,35 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/bench": "^0.1.0", - "@stdlib/math-base-assert-is-nan": "^0.1.1", - "@stdlib/random-base-randu": "^0.1.0", - "@stdlib/string-repeat": "^0.1.0", - "@stdlib/utils-noop": "^0.1.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..1478eae --- /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 0952b56..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,328 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 whileAsync = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof whileAsync, 'function', 'main export is a function' ); - t.end(); -}); - -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() { - whileAsync( value, noop, 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() { - whileAsync( noop, value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a callback 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() { - whileAsync( noop, noop, value ); - }; - } -}); - -tape( 'while a test condition is true, the function invokes a provided function', function test( t ) { - var indices1 = [ 0, 1, 2, 3, 4, 5 ]; - var indices2 = [ 0, 1, 2, 3, 4 ]; - var j = -1; - var k = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices1[ j ], 'provides expected value' ); - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - k += 1; - t.strictEqual( i, indices2[ k ], 'provides expected value' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'while a test condition is true, the function invokes a provided function (always false)', function test( t ) { - var indices = [ 0 ]; - var j = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices[ j ], 'provides expected value' ); - clbk( null, false ); - } - - function fcn( i, next ) { - t.fail( 'should never be invoked' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx = { - 'count': 0 - }; - - whileAsync( predicate, fcn, done, ctx ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - this.count += 1; // eslint-disable-line no-invalid-this - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( ctx.count, 5, 'updates context' ); - t.end(); - } -}); - -tape( 'the function provides any results to a `done` callback', function test( t ) { - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, 'beep'+i, 'boop'+i, 'woot'+i ); - } - } - - function done( error, str1, str2, str3 ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( str1, 'beep4', 'returns expected value' ); - t.strictEqual( str2, 'boop4', 'returns expected value' ); - t.strictEqual( str3, 'woot4', 'returns expected value' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the predicate function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - if ( i === 1 ) { - return clbk( new Error( 'beep' ) ); - } - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 2, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the provided function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - if ( i === 2 ) { - return next( new Error( 'boop' ) ); - } - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 3, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'the function does not guarantee asynchronous execution', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - k = 1; - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - next(); - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( k, 0, 'releases the zalgo' ); - t.end(); - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 78d0688..0000000 --- a/test/test.js +++ /dev/null @@ -1,328 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 whileAsync = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof whileAsync, 'function', 'main export is a function' ); - t.end(); -}); - -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() { - whileAsync( value, noop, 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() { - whileAsync( noop, value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a callback 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() { - whileAsync( noop, noop, value ); - }; - } -}); - -tape( 'while a test condition is true, the function invokes a provided function', function test( t ) { - var indices1 = [ 0, 1, 2, 3, 4, 5 ]; - var indices2 = [ 0, 1, 2, 3, 4 ]; - var j = -1; - var k = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices1[ j ], 'provides expected value' ); - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - k += 1; - t.strictEqual( i, indices2[ k ], 'provides expected value' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'while a test condition is true, the function invokes a provided function (always false)', function test( t ) { - var indices = [ 0 ]; - var j = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices[ j ], 'provides expected value' ); - clbk( null, false ); - } - - function fcn( i, next ) { - t.fail( 'should never be invoked' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx = { - 'count': 0 - }; - - whileAsync( predicate, fcn, done, ctx ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - this.count += 1; // eslint-disable-line no-invalid-this - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( ctx.count, 5, 'updates context' ); - t.end(); - } -}); - -tape( 'the function provides any results to a `done` callback', function test( t ) { - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, 'beep'+i, 'boop'+i, 'woot'+i ); - } - } - - function done( error, str1, str2, str3 ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( str1, 'beep4', 'returns expected value' ); - t.strictEqual( str2, 'boop4', 'returns expected value' ); - t.strictEqual( str3, 'woot4', 'returns expected value' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the predicate function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - if ( i === 1 ) { - return clbk( new Error( 'beep' ) ); - } - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 2, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the provided function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - if ( i === 2 ) { - return next( new Error( 'boop' ) ); - } - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 3, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'the function does not guarantee asynchronous execution', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - k = 1; - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - next(); - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( k, 0, 'releases the zalgo' ); - t.end(); - } -}); From cc98710571506d4d7e9d47982660eb9a28c764ed Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Nov 2023 01:53:51 +0000 Subject: [PATCH 075/143] 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 1dafc2a..2da009c 100644 --- a/lib/main.js +++ b/lib/main.js @@ -21,7 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -62,13 +62,13 @@ function whileAsync( predicate, fcn, done, thisArg ) { var args; var idx; if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '1Rr3c,J9', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '1Rr2H,G6', fcn ) ); } if ( !isFunction( done ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', done ) ); + throw new TypeError( format( '1Rr3N,G4', done ) ); } args = []; idx = 0; diff --git a/package.json b/package.json index 00f11ce..2167257 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ }, "dependencies": { "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/string-format": "^0.1.1" + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/bench": "^0.1.0", From 12447afe62076becb40285044f5695f42dcdb557 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Nov 2023 16:36:24 +0000 Subject: [PATCH 076/143] Remove files --- index.d.ts | 127 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6309 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 09e781e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,127 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Callback function. -*/ -type Nullary = () => void; - -/** -* Callback function. -* -* @param error - encountered error or null -*/ -type Unary = ( error: Error | null ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Binary = ( error: Error | null, bool: boolean ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Callback = Nullary | Unary | Binary; - -/** -* Callback invoked upon completion. -*/ -type DoneNullary = () => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -*/ -type DoneUnary = ( error: Error | null ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneBinary = ( error: Error | null, ...args: Array ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneCallback = DoneNullary | DoneUnary | DoneBinary; - -/** -* Checks whether an element in a collection passes a test. -* -* @param i - iteration number (starting from one) -* @param clbk - a callback indicating whether to invoke `fcn` -*/ -type Predicate = ( i: number, clbk: Callback ) => void; - -/** -* Invoked function. -* -* @param i - iteration number (starting from zero) -* @param next - a callback which must be invoked before proceeding to the next iteration -*/ -type Fcn = ( i: number, next: Function ) => void; - -/** -* Invokes a function while a test condition is true. -* -* @param predicate - function which indicates whether to continue invoking a function -* @param fcn - function to invoke -* @param done - callback to invoke upon completion -* @param thisArg - execution context for the invoked function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -declare function whileAsync( predicate: Predicate, fcn: Fcn, done: DoneCallback, thisArg?: any ): void; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = whileAsync; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 32e669e..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-function@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";function n(n,e,o,i){var s,l;if(!r(n))throw new TypeError(t("1Rr3c,J9",n));if(!r(e))throw new TypeError(t("1Rr2H,G6",e));if(!r(o))throw new TypeError(t("1Rr3N,G4",o));function f(r,t){return r?o(r):t?e.call(i,l,h):(s.length&&s.unshift(null),void o.apply(null,s))}function h(r){var t;if(r)return o(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;8LA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,WAAYR,IAE1C,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,WAAYP,IAE1C,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAc1C,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 1478eae..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 4275ec70e754873e68743dddb1df03f1936a6977 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Nov 2023 16:39:53 +0000 Subject: [PATCH 077/143] 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 | 105 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 72 - docs/types/test.ts | 83 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 57 - lib/main.js | 128 - package.json | 56 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 328 -- 42 files changed, 6202 insertions(+), 4166 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 (100%) 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 32470db..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-11-01T01:04:55.523Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 0f8dec8..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/async/while) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 9633c26..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/async/while) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 ee192db..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: '8 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' - # 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 + + ```
@@ -290,7 +283,7 @@ whileAsync( predicate, fcn, done ); ## 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]. @@ -352,13 +345,13 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until +[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until/tree/esm -[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while +[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while/tree/esm -[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until +[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until/tree/esm -[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while +[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index ae9d749..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var whileAsync = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); - -bench( pkg+'::sync_predicate', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1e936a1..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/async/while" -%% click B href "https://github.com/stdlib-js/utils-async-while/tree/main" -%% click C href "https://github.com/stdlib-js/utils-async-while/tree/production" -%% click D href "https://github.com/stdlib-js/utils-async-while/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-async-while/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-async-while/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/async/while -[production-url]: https://github.com/stdlib-js/utils-async-while/tree/production -[deno-url]: https://github.com/stdlib-js/utils-async-while/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-async-while/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-async-while/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 efdafdf..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import whileAsync from '../docs/types/index'; -export = whileAsync; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 159efee..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var v=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var m=v(function(p,g){ -var s=require('@stdlib/assert-is-function/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist');function c(t,r,e,o){var u,i;if(!s(t))throw new TypeError(l('1Rr3c',t));if(!s(r))throw new TypeError(l('1Rr2H',r));if(!s(e))throw new TypeError(l('1Rr3N',e));u=[],i=0,t(i,f);function f(a,n){if(a)return e(a);if(n)return r.call(o,i,h);u.length&&u.unshift(null),e.apply(null,u)}function h(a){var n;if(a)return e(a);if(i+=1,arguments.length>1)for(u=new Array(arguments.length-1),n=1;n 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = whileAsync;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Invoke a function while a test condition is true.\n*\n* @module @stdlib/utils-async-while\n*\n* @example\n* var whileAsync = require( '@stdlib/utils-async-while' );\n*\n* function predicate( i, clbk ) {\n* clbk( null, i < 5 );\n* }\n*\n* function fcn( i, next ) {\n* setTimeout( onTimeout, i );\n* function onTimeout() {\n* console.log( 'beep: %d', i );\n* next();\n* }\n* }\n*\n* function done( error ) {\n* if ( error ) {\n* throw error;\n* }\n* }\n*\n* whileAsync( predicate, fcn, done );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAS,QAAS,uBAAwB,EAqC9C,SAASC,EAAYC,EAAWC,EAAKC,EAAMC,EAAU,CACpD,IAAIC,EACAC,EACJ,GAAK,CAACR,EAAYG,CAAU,EAC3B,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAU,CAAE,EAE/G,GAAK,CAACH,EAAYI,CAAI,EACrB,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAI,CAAE,EAE1G,GAAK,CAACJ,EAAYK,CAAK,EACtB,MAAM,IAAI,UAAWJ,EAAQ,oEAAqEI,CAAK,CAAE,EAE1GE,EAAO,CAAC,EACRC,EAAM,EACNL,EAAWK,EAAKC,CAAY,EAU5B,SAASA,EAAaC,EAAOC,EAAS,CACrC,GAAKD,EACJ,OAAOL,EAAMK,CAAM,EAEpB,GAAKC,EACJ,OAAOP,EAAI,KAAME,EAASE,EAAKI,CAAK,EAEhCL,EAAK,QACTA,EAAK,QAAS,IAAK,EAEpBF,EAAK,MAAO,KAAME,CAAK,CACxB,CAUA,SAASK,EAAMF,EAAQ,CACtB,IAAIG,EACJ,GAAKH,EACJ,OAAOL,EAAMK,CAAM,EAKpB,GAHAF,GAAO,EAGF,UAAU,OAAS,EAEvB,IADAD,EAAO,IAAI,MAAO,UAAU,OAAO,CAAE,EAC/BM,EAAI,EAAGA,EAAI,UAAU,OAAQA,IAClCN,EAAMM,EAAE,CAAE,EAAI,UAAWA,CAAE,EAI7BV,EAAWK,EAAKC,CAAY,CAC7B,CACD,CAKAV,EAAO,QAAUG,IC5EjB,IAAIY,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "format", "whileAsync", "predicate", "fcn", "done", "thisArg", "args", "idx", "onPredicate", "error", "result", "next", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index d7ca8c9..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,72 +0,0 @@ - -{{alias}}( predicate, fcn, done[, thisArg] ) - Invokes a function while a test condition is true. - - The predicate function is provided two arguments: - - - `i`: iteration number (starting from zero) - - `clbk`: a callback indicating whether to invoke `fcn` - - The `clbk` function accepts two arguments: - - - `error`: error argument - - `bool`: test result - - If the test result is truthy, the function invokes `fcn`; otherwise, the - function invokes the `done` callback. - - The function to invoke is provided two arguments: - - - `i`: iteration number (starting from zero) - - `next`: a callback which must be invoked before proceeding to the next - iteration - - The first argument of the `next` callback is an `error` argument. If `fcn` - calls the `next` callback with a truthy `error` argument, the function - suspends execution and immediately calls the `done` callback for subsequent - `error` handling. - - The `done` callback is invoked with an `error` argument and any arguments - passed to the final `next` callback. - - Execution is *not* guaranteed to be asynchronous. To guarantee asynchrony, - wrap the `done` callback in a function which either executes at the end of - the current stack (e.g., `nextTick`) or during a subsequent turn of the - event loop (e.g., `setImmediate`, `setTimeout`). - - Parameters - ---------- - predicate: Function - The predicate function which indicates whether to continue invoking a - function. - - fcn: Function - The function to invoke. - - done: Function - Callback to invoke upon completion. - - thisArg: any (optional) - Execution context for the invoked function. - - Examples - -------- - > function predicate( i, clbk ) { clbk( null, i < 5 ); }; - > function fcn( i, next ) { - ... setTimeout( onTimeout, i ); - ... function onTimeout() { - ... next( null, 'boop'+i ); - ... } - ... }; - > function done( error, result ) { - ... if ( error ) { - ... throw error; - ... } - ... console.log( result ); - ... }; - > {{alias}}( predicate, fcn, done ) - boop: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4a543d9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,83 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 whileAsync = require( './index' ); - -const fcn = ( i: number, next: Function ): void => { - if ( i === void 0 ) { - throw new Error( '`i` is missing.' ); - } - next(); -}; - -const predicate = ( i: number, clbk: Function ): void => { - clbk( null, i < 5 ); -}; - -const done = ( error: Error | null ): void => { - if ( error ) { - throw error; - } -}; - - -// TESTS // - -// The function returns void... -{ - whileAsync( predicate, fcn, done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a predicate function... -{ - whileAsync( 2, fcn, done ); // $ExpectError - whileAsync( false, fcn, done ); // $ExpectError - whileAsync( true, fcn, done ); // $ExpectError - whileAsync( 'abc', fcn, done ); // $ExpectError - whileAsync( {}, fcn, done ); // $ExpectError - whileAsync( [], fcn, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function having a supported signature... -{ - whileAsync( predicate, 2, done ); // $ExpectError - whileAsync( predicate, false, done ); // $ExpectError - whileAsync( predicate, true, done ); // $ExpectError - whileAsync( predicate, 'abc', done ); // $ExpectError - whileAsync( predicate, {}, done ); // $ExpectError - whileAsync( predicate, [], done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a done callback argument which is not a function having a supported signature... -{ - whileAsync( predicate, fcn, 2 ); // $ExpectError - whileAsync( predicate, fcn, false ); // $ExpectError - whileAsync( predicate, fcn, true ); // $ExpectError - whileAsync( predicate, fcn, 'abc' ); // $ExpectError - whileAsync( predicate, fcn, {} ); // $ExpectError - whileAsync( predicate, fcn, [] ); // $ExpectError - whileAsync( predicate, fcn, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - whileAsync(); // $ExpectError - whileAsync( predicate ); // $ExpectError - whileAsync( predicate, fcn ); // $ExpectError - whileAsync( predicate, fcn, done, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a6af668..0000000 --- a/examples/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var repeatString = require( '@stdlib/string-repeat' ); -var whileAsync = require( './../lib' ); - -function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } -} - -function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, repeatString( 'beep', i+1 ) ); - } -} - -function done( error, result ) { - if ( error ) { - throw error; - } - console.log( result ); -} - -whileAsync( predicate, fcn, done ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..32e669e --- /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-function@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";function n(n,e,o,i){var s,l;if(!r(n))throw new TypeError(t("1Rr3c,J9",n));if(!r(e))throw new TypeError(t("1Rr2H,G6",e));if(!r(o))throw new TypeError(t("1Rr3N,G4",o));function f(r,t){return r?o(r):t?e.call(i,l,h):(s.length&&s.unshift(null),void o.apply(null,s))}function h(r){var t;if(r)return o(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;8LA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,WAAYR,IAE1C,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,WAAYP,IAE1C,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAc1C,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a13bd4..0000000 --- a/lib/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Invoke a function while a test condition is true. -* -* @module @stdlib/utils-async-while -* -* @example -* var whileAsync = require( '@stdlib/utils-async-while' ); -* -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 2da009c..0000000 --- a/lib/main.js +++ /dev/null @@ -1,128 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Invokes a function while a test condition is true. -* -* @param {Function} predicate - function which indicates whether to continue invoking a function -* @param {Function} fcn - function to invoke -* @param {Callback} done - callback to invoke upon completion -* @param {*} [thisArg] - execution context for the invoked function -* @throws {TypeError} first argument must be a function -* @throws {TypeError} second argument must be a function -* @throws {TypeError} third argument must be a function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -function whileAsync( predicate, fcn, done, thisArg ) { - var args; - var idx; - if ( !isFunction( predicate ) ) { - throw new TypeError( format( '1Rr3c,J9', predicate ) ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '1Rr2H,G6', fcn ) ); - } - if ( !isFunction( done ) ) { - throw new TypeError( format( '1Rr3N,G4', done ) ); - } - args = []; - idx = 0; - predicate( idx, onPredicate ); - - /** - * Callback invoked upon a predicate result. - * - * @private - * @param {(Error|null)} error - error object - * @param {boolean} result - predicate result - * @returns {void} - */ - function onPredicate( error, result ) { - if ( error ) { - return done( error ); - } - if ( result ) { - return fcn.call( thisArg, idx, next ); - } - if ( args.length ) { - args.unshift( null ); // error argument - } - done.apply( null, args ); - } - - /** - * Callback invoked upon completion of a provided function. - * - * @private - * @param {(Error|null)} error - error object - * @param {...*} results - function results - * @returns {void} - */ - function next( error ) { - var i; - if ( error ) { - return done( error ); - } - idx += 1; - - // Cache the most recent results... - if ( arguments.length > 1 ) { - args = new Array( arguments.length-1 ); - for ( i = 1; i < arguments.length; i++ ) { - args[ i-1 ] = arguments[ i ]; - } - } - // Run the test condition: - predicate( idx, onPredicate ); - } -} - - -// EXPORTS // - -module.exports = whileAsync; diff --git a/package.json b/package.json index 2167257..751474c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Invoke a function while a test condition is true.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,35 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/bench": "^0.1.0", - "@stdlib/math-base-assert-is-nan": "^0.1.1", - "@stdlib/random-base-randu": "^0.1.0", - "@stdlib/string-repeat": "^0.1.0", - "@stdlib/utils-noop": "^0.1.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..348046b --- /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 78d0688..0000000 --- a/test/test.js +++ /dev/null @@ -1,328 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 whileAsync = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof whileAsync, 'function', 'main export is a function' ); - t.end(); -}); - -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() { - whileAsync( value, noop, 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() { - whileAsync( noop, value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a callback 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() { - whileAsync( noop, noop, value ); - }; - } -}); - -tape( 'while a test condition is true, the function invokes a provided function', function test( t ) { - var indices1 = [ 0, 1, 2, 3, 4, 5 ]; - var indices2 = [ 0, 1, 2, 3, 4 ]; - var j = -1; - var k = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices1[ j ], 'provides expected value' ); - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - k += 1; - t.strictEqual( i, indices2[ k ], 'provides expected value' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'while a test condition is true, the function invokes a provided function (always false)', function test( t ) { - var indices = [ 0 ]; - var j = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices[ j ], 'provides expected value' ); - clbk( null, false ); - } - - function fcn( i, next ) { - t.fail( 'should never be invoked' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx = { - 'count': 0 - }; - - whileAsync( predicate, fcn, done, ctx ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - this.count += 1; // eslint-disable-line no-invalid-this - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( ctx.count, 5, 'updates context' ); - t.end(); - } -}); - -tape( 'the function provides any results to a `done` callback', function test( t ) { - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, 'beep'+i, 'boop'+i, 'woot'+i ); - } - } - - function done( error, str1, str2, str3 ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( str1, 'beep4', 'returns expected value' ); - t.strictEqual( str2, 'boop4', 'returns expected value' ); - t.strictEqual( str3, 'woot4', 'returns expected value' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the predicate function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - if ( i === 1 ) { - return clbk( new Error( 'beep' ) ); - } - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 2, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the provided function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - if ( i === 2 ) { - return next( new Error( 'boop' ) ); - } - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 3, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'the function does not guarantee asynchronous execution', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - k = 1; - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - next(); - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( k, 0, 'releases the zalgo' ); - t.end(); - } -}); From 7c1f4c488b5a1c9dd6f453346d024e96822d1618 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Dec 2023 01:52:21 +0000 Subject: [PATCH 078/143] 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 1dafc2a..2da009c 100644 --- a/lib/main.js +++ b/lib/main.js @@ -21,7 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -62,13 +62,13 @@ function whileAsync( predicate, fcn, done, thisArg ) { var args; var idx; if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '1Rr3c,J9', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '1Rr2H,G6', fcn ) ); } if ( !isFunction( done ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', done ) ); + throw new TypeError( format( '1Rr3N,G4', done ) ); } args = []; idx = 0; diff --git a/package.json b/package.json index e76971b..6b66eba 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ }, "dependencies": { "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/string-format": "^0.1.1" + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/bench": "^0.2.1", From 34b0da4b1bd7a201066d7b053b4e81270196bc44 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Dec 2023 10:08:19 +0000 Subject: [PATCH 079/143] Remove files --- index.d.ts | 127 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6309 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 09e781e..0000000 --- a/index.d.ts +++ /dev/null @@ -1,127 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Callback function. -*/ -type Nullary = () => void; - -/** -* Callback function. -* -* @param error - encountered error or null -*/ -type Unary = ( error: Error | null ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Binary = ( error: Error | null, bool: boolean ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Callback = Nullary | Unary | Binary; - -/** -* Callback invoked upon completion. -*/ -type DoneNullary = () => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -*/ -type DoneUnary = ( error: Error | null ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneBinary = ( error: Error | null, ...args: Array ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneCallback = DoneNullary | DoneUnary | DoneBinary; - -/** -* Checks whether an element in a collection passes a test. -* -* @param i - iteration number (starting from one) -* @param clbk - a callback indicating whether to invoke `fcn` -*/ -type Predicate = ( i: number, clbk: Callback ) => void; - -/** -* Invoked function. -* -* @param i - iteration number (starting from zero) -* @param next - a callback which must be invoked before proceeding to the next iteration -*/ -type Fcn = ( i: number, next: Function ) => void; - -/** -* Invokes a function while a test condition is true. -* -* @param predicate - function which indicates whether to continue invoking a function -* @param fcn - function to invoke -* @param done - callback to invoke upon completion -* @param thisArg - execution context for the invoked function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -declare function whileAsync( predicate: Predicate, fcn: Fcn, done: DoneCallback, thisArg?: any ): void; // tslint-disable-line max-line-length - - -// EXPORTS // - -export = whileAsync; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 32e669e..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-function@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";function n(n,e,o,i){var s,l;if(!r(n))throw new TypeError(t("1Rr3c,J9",n));if(!r(e))throw new TypeError(t("1Rr2H,G6",e));if(!r(o))throw new TypeError(t("1Rr3N,G4",o));function f(r,t){return r?o(r):t?e.call(i,l,h):(s.length&&s.unshift(null),void o.apply(null,s))}function h(r){var t;if(r)return o(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;8LA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,WAAYR,IAE1C,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,WAAYP,IAE1C,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAc1C,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 348046b..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 6bfa9907cac8326df0aacc48880118321a73e17d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Dec 2023 10:10:50 +0000 Subject: [PATCH 080/143] 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 | 105 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 72 - docs/types/test.ts | 83 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 57 - lib/main.js | 128 - package.json | 56 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 328 -- 42 files changed, 6202 insertions(+), 4161 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 (100%) 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 9faec54..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-12-01T01:09:01.051Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 0f8dec8..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/async/while) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 9633c26..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/async/while) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 ee192db..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: '8 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' - # 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 + + ```
@@ -290,7 +283,7 @@ whileAsync( predicate, fcn, done ); ## 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]. @@ -352,13 +345,13 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until +[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until/tree/esm -[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while +[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while/tree/esm -[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until +[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until/tree/esm -[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while +[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index ae9d749..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var whileAsync = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); - -bench( pkg+'::sync_predicate', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1e936a1..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/async/while" -%% click B href "https://github.com/stdlib-js/utils-async-while/tree/main" -%% click C href "https://github.com/stdlib-js/utils-async-while/tree/production" -%% click D href "https://github.com/stdlib-js/utils-async-while/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-async-while/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-async-while/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/async/while -[production-url]: https://github.com/stdlib-js/utils-async-while/tree/production -[deno-url]: https://github.com/stdlib-js/utils-async-while/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-async-while/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-async-while/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 efdafdf..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import whileAsync from '../docs/types/index'; -export = whileAsync; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 159efee..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var v=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var m=v(function(p,g){ -var s=require('@stdlib/assert-is-function/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist');function c(t,r,e,o){var u,i;if(!s(t))throw new TypeError(l('1Rr3c',t));if(!s(r))throw new TypeError(l('1Rr2H',r));if(!s(e))throw new TypeError(l('1Rr3N',e));u=[],i=0,t(i,f);function f(a,n){if(a)return e(a);if(n)return r.call(o,i,h);u.length&&u.unshift(null),e.apply(null,u)}function h(a){var n;if(a)return e(a);if(i+=1,arguments.length>1)for(u=new Array(arguments.length-1),n=1;n 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = whileAsync;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Invoke a function while a test condition is true.\n*\n* @module @stdlib/utils-async-while\n*\n* @example\n* var whileAsync = require( '@stdlib/utils-async-while' );\n*\n* function predicate( i, clbk ) {\n* clbk( null, i < 5 );\n* }\n*\n* function fcn( i, next ) {\n* setTimeout( onTimeout, i );\n* function onTimeout() {\n* console.log( 'beep: %d', i );\n* next();\n* }\n* }\n*\n* function done( error ) {\n* if ( error ) {\n* throw error;\n* }\n* }\n*\n* whileAsync( predicate, fcn, done );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAS,QAAS,uBAAwB,EAqC9C,SAASC,EAAYC,EAAWC,EAAKC,EAAMC,EAAU,CACpD,IAAIC,EACAC,EACJ,GAAK,CAACR,EAAYG,CAAU,EAC3B,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAU,CAAE,EAE/G,GAAK,CAACH,EAAYI,CAAI,EACrB,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAI,CAAE,EAE1G,GAAK,CAACJ,EAAYK,CAAK,EACtB,MAAM,IAAI,UAAWJ,EAAQ,oEAAqEI,CAAK,CAAE,EAE1GE,EAAO,CAAC,EACRC,EAAM,EACNL,EAAWK,EAAKC,CAAY,EAU5B,SAASA,EAAaC,EAAOC,EAAS,CACrC,GAAKD,EACJ,OAAOL,EAAMK,CAAM,EAEpB,GAAKC,EACJ,OAAOP,EAAI,KAAME,EAASE,EAAKI,CAAK,EAEhCL,EAAK,QACTA,EAAK,QAAS,IAAK,EAEpBF,EAAK,MAAO,KAAME,CAAK,CACxB,CAUA,SAASK,EAAMF,EAAQ,CACtB,IAAIG,EACJ,GAAKH,EACJ,OAAOL,EAAMK,CAAM,EAKpB,GAHAF,GAAO,EAGF,UAAU,OAAS,EAEvB,IADAD,EAAO,IAAI,MAAO,UAAU,OAAO,CAAE,EAC/BM,EAAI,EAAGA,EAAI,UAAU,OAAQA,IAClCN,EAAMM,EAAE,CAAE,EAAI,UAAWA,CAAE,EAI7BV,EAAWK,EAAKC,CAAY,CAC7B,CACD,CAKAV,EAAO,QAAUG,IC5EjB,IAAIY,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "format", "whileAsync", "predicate", "fcn", "done", "thisArg", "args", "idx", "onPredicate", "error", "result", "next", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index d7ca8c9..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,72 +0,0 @@ - -{{alias}}( predicate, fcn, done[, thisArg] ) - Invokes a function while a test condition is true. - - The predicate function is provided two arguments: - - - `i`: iteration number (starting from zero) - - `clbk`: a callback indicating whether to invoke `fcn` - - The `clbk` function accepts two arguments: - - - `error`: error argument - - `bool`: test result - - If the test result is truthy, the function invokes `fcn`; otherwise, the - function invokes the `done` callback. - - The function to invoke is provided two arguments: - - - `i`: iteration number (starting from zero) - - `next`: a callback which must be invoked before proceeding to the next - iteration - - The first argument of the `next` callback is an `error` argument. If `fcn` - calls the `next` callback with a truthy `error` argument, the function - suspends execution and immediately calls the `done` callback for subsequent - `error` handling. - - The `done` callback is invoked with an `error` argument and any arguments - passed to the final `next` callback. - - Execution is *not* guaranteed to be asynchronous. To guarantee asynchrony, - wrap the `done` callback in a function which either executes at the end of - the current stack (e.g., `nextTick`) or during a subsequent turn of the - event loop (e.g., `setImmediate`, `setTimeout`). - - Parameters - ---------- - predicate: Function - The predicate function which indicates whether to continue invoking a - function. - - fcn: Function - The function to invoke. - - done: Function - Callback to invoke upon completion. - - thisArg: any (optional) - Execution context for the invoked function. - - Examples - -------- - > function predicate( i, clbk ) { clbk( null, i < 5 ); }; - > function fcn( i, next ) { - ... setTimeout( onTimeout, i ); - ... function onTimeout() { - ... next( null, 'boop'+i ); - ... } - ... }; - > function done( error, result ) { - ... if ( error ) { - ... throw error; - ... } - ... console.log( result ); - ... }; - > {{alias}}( predicate, fcn, done ) - boop: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4a543d9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,83 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 whileAsync = require( './index' ); - -const fcn = ( i: number, next: Function ): void => { - if ( i === void 0 ) { - throw new Error( '`i` is missing.' ); - } - next(); -}; - -const predicate = ( i: number, clbk: Function ): void => { - clbk( null, i < 5 ); -}; - -const done = ( error: Error | null ): void => { - if ( error ) { - throw error; - } -}; - - -// TESTS // - -// The function returns void... -{ - whileAsync( predicate, fcn, done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a predicate function... -{ - whileAsync( 2, fcn, done ); // $ExpectError - whileAsync( false, fcn, done ); // $ExpectError - whileAsync( true, fcn, done ); // $ExpectError - whileAsync( 'abc', fcn, done ); // $ExpectError - whileAsync( {}, fcn, done ); // $ExpectError - whileAsync( [], fcn, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function having a supported signature... -{ - whileAsync( predicate, 2, done ); // $ExpectError - whileAsync( predicate, false, done ); // $ExpectError - whileAsync( predicate, true, done ); // $ExpectError - whileAsync( predicate, 'abc', done ); // $ExpectError - whileAsync( predicate, {}, done ); // $ExpectError - whileAsync( predicate, [], done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a done callback argument which is not a function having a supported signature... -{ - whileAsync( predicate, fcn, 2 ); // $ExpectError - whileAsync( predicate, fcn, false ); // $ExpectError - whileAsync( predicate, fcn, true ); // $ExpectError - whileAsync( predicate, fcn, 'abc' ); // $ExpectError - whileAsync( predicate, fcn, {} ); // $ExpectError - whileAsync( predicate, fcn, [] ); // $ExpectError - whileAsync( predicate, fcn, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - whileAsync(); // $ExpectError - whileAsync( predicate ); // $ExpectError - whileAsync( predicate, fcn ); // $ExpectError - whileAsync( predicate, fcn, done, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a6af668..0000000 --- a/examples/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var repeatString = require( '@stdlib/string-repeat' ); -var whileAsync = require( './../lib' ); - -function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } -} - -function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, repeatString( 'beep', i+1 ) ); - } -} - -function done( error, result ) { - if ( error ) { - throw error; - } - console.log( result ); -} - -whileAsync( predicate, fcn, done ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..32e669e --- /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-function@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";function n(n,e,o,i){var s,l;if(!r(n))throw new TypeError(t("1Rr3c,J9",n));if(!r(e))throw new TypeError(t("1Rr2H,G6",e));if(!r(o))throw new TypeError(t("1Rr3N,G4",o));function f(r,t){return r?o(r):t?e.call(i,l,h):(s.length&&s.unshift(null),void o.apply(null,s))}function h(r){var t;if(r)return o(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;8LA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,WAAYR,IAE1C,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,WAAYP,IAE1C,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAc1C,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a13bd4..0000000 --- a/lib/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Invoke a function while a test condition is true. -* -* @module @stdlib/utils-async-while -* -* @example -* var whileAsync = require( '@stdlib/utils-async-while' ); -* -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 2da009c..0000000 --- a/lib/main.js +++ /dev/null @@ -1,128 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Invokes a function while a test condition is true. -* -* @param {Function} predicate - function which indicates whether to continue invoking a function -* @param {Function} fcn - function to invoke -* @param {Callback} done - callback to invoke upon completion -* @param {*} [thisArg] - execution context for the invoked function -* @throws {TypeError} first argument must be a function -* @throws {TypeError} second argument must be a function -* @throws {TypeError} third argument must be a function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -function whileAsync( predicate, fcn, done, thisArg ) { - var args; - var idx; - if ( !isFunction( predicate ) ) { - throw new TypeError( format( '1Rr3c,J9', predicate ) ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '1Rr2H,G6', fcn ) ); - } - if ( !isFunction( done ) ) { - throw new TypeError( format( '1Rr3N,G4', done ) ); - } - args = []; - idx = 0; - predicate( idx, onPredicate ); - - /** - * Callback invoked upon a predicate result. - * - * @private - * @param {(Error|null)} error - error object - * @param {boolean} result - predicate result - * @returns {void} - */ - function onPredicate( error, result ) { - if ( error ) { - return done( error ); - } - if ( result ) { - return fcn.call( thisArg, idx, next ); - } - if ( args.length ) { - args.unshift( null ); // error argument - } - done.apply( null, args ); - } - - /** - * Callback invoked upon completion of a provided function. - * - * @private - * @param {(Error|null)} error - error object - * @param {...*} results - function results - * @returns {void} - */ - function next( error ) { - var i; - if ( error ) { - return done( error ); - } - idx += 1; - - // Cache the most recent results... - if ( arguments.length > 1 ) { - args = new Array( arguments.length-1 ); - for ( i = 1; i < arguments.length; i++ ) { - args[ i-1 ] = arguments[ i ]; - } - } - // Run the test condition: - predicate( idx, onPredicate ); - } -} - - -// EXPORTS // - -module.exports = whileAsync; diff --git a/package.json b/package.json index 6b66eba..751474c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Invoke a function while a test condition is true.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,35 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/bench": "^0.2.1", - "@stdlib/math-base-assert-is-nan": "^0.1.1", - "@stdlib/random-base-randu": "^0.1.0", - "@stdlib/string-repeat": "^0.1.0", - "@stdlib/utils-noop": "^0.1.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..4163320 --- /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 78d0688..0000000 --- a/test/test.js +++ /dev/null @@ -1,328 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 whileAsync = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof whileAsync, 'function', 'main export is a function' ); - t.end(); -}); - -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() { - whileAsync( value, noop, 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() { - whileAsync( noop, value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a callback 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() { - whileAsync( noop, noop, value ); - }; - } -}); - -tape( 'while a test condition is true, the function invokes a provided function', function test( t ) { - var indices1 = [ 0, 1, 2, 3, 4, 5 ]; - var indices2 = [ 0, 1, 2, 3, 4 ]; - var j = -1; - var k = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices1[ j ], 'provides expected value' ); - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - k += 1; - t.strictEqual( i, indices2[ k ], 'provides expected value' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'while a test condition is true, the function invokes a provided function (always false)', function test( t ) { - var indices = [ 0 ]; - var j = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices[ j ], 'provides expected value' ); - clbk( null, false ); - } - - function fcn( i, next ) { - t.fail( 'should never be invoked' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx = { - 'count': 0 - }; - - whileAsync( predicate, fcn, done, ctx ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - this.count += 1; // eslint-disable-line no-invalid-this - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( ctx.count, 5, 'updates context' ); - t.end(); - } -}); - -tape( 'the function provides any results to a `done` callback', function test( t ) { - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, 'beep'+i, 'boop'+i, 'woot'+i ); - } - } - - function done( error, str1, str2, str3 ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( str1, 'beep4', 'returns expected value' ); - t.strictEqual( str2, 'boop4', 'returns expected value' ); - t.strictEqual( str3, 'woot4', 'returns expected value' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the predicate function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - if ( i === 1 ) { - return clbk( new Error( 'beep' ) ); - } - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 2, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the provided function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - if ( i === 2 ) { - return next( new Error( 'boop' ) ); - } - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 3, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'the function does not guarantee asynchronous execution', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - k = 1; - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - next(); - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( k, 0, 'releases the zalgo' ); - t.end(); - } -}); From a4086e5e3ca07a6e02368b9f693868306e2d9346 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 01:41:14 +0000 Subject: [PATCH 081/143] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a45fa9c..f1ad12e 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ }, "dependencies": { "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/string-format": "^0.1.1" + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/math-base-assert-is-nan": "^0.1.1", From 4521f9ab858e4217d7949379946db41273458b7a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 04:31:50 +0000 Subject: [PATCH 082/143] Remove files --- index.d.ts | 127 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6309 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 163e8ba..0000000 --- a/index.d.ts +++ /dev/null @@ -1,127 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Callback function. -*/ -type Nullary = () => void; - -/** -* Callback function. -* -* @param error - encountered error or null -*/ -type Unary = ( error: Error | null ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Binary = ( error: Error | null, bool: boolean ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Callback = Nullary | Unary | Binary; - -/** -* Callback invoked upon completion. -*/ -type DoneNullary = () => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -*/ -type DoneUnary = ( error: Error | null ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneBinary = ( error: Error | null, ...args: Array ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneCallback = DoneNullary | DoneUnary | DoneBinary; - -/** -* Checks whether an element in a collection passes a test. -* -* @param i - iteration number (starting from one) -* @param clbk - a callback indicating whether to invoke `fcn` -*/ -type Predicate = ( i: number, clbk: Callback ) => void; - -/** -* Invoked function. -* -* @param i - iteration number (starting from zero) -* @param next - a callback which must be invoked before proceeding to the next iteration -*/ -type Fcn = ( i: number, next: Function ) => void; - -/** -* Invokes a function while a test condition is true. -* -* @param predicate - function which indicates whether to continue invoking a function -* @param fcn - function to invoke -* @param done - callback to invoke upon completion -* @param thisArg - execution context for the invoked function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -declare function whileAsync( predicate: Predicate, fcn: Fcn, done: DoneCallback, thisArg?: any ): void; - - -// EXPORTS // - -export = whileAsync; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 32e669e..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-function@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";function n(n,e,o,i){var s,l;if(!r(n))throw new TypeError(t("1Rr3c,J9",n));if(!r(e))throw new TypeError(t("1Rr2H,G6",e));if(!r(o))throw new TypeError(t("1Rr3N,G4",o));function f(r,t){return r?o(r):t?e.call(i,l,h):(s.length&&s.unshift(null),void o.apply(null,s))}function h(r){var t;if(r)return o(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;8LA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,WAAYR,IAE1C,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,WAAYP,IAE1C,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,WAAYN,IAc1C,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 4163320..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From feb2b25157289138e6896fab093426295e538660 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 04:32:12 +0000 Subject: [PATCH 083/143] 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 | 105 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 72 - docs/types/test.ts | 83 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 57 - lib/main.js | 128 - package.json | 56 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 328 -- 43 files changed, 6202 insertions(+), 4167 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 (100%) 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 f33c9e7..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-01-01T01:03:21.863Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 0f8dec8..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/async/while) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 9633c26..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/async/while) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 f056373..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: '8 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' - # 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 + + ```
@@ -290,7 +283,7 @@ whileAsync( predicate, fcn, done ); ## 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]. @@ -352,13 +345,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until +[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until/tree/esm -[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while +[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while/tree/esm -[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until +[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until/tree/esm -[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while +[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while/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 7c83acf..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var whileAsync = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); - -bench( pkg+'::sync_predicate', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1e936a1..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/async/while" -%% click B href "https://github.com/stdlib-js/utils-async-while/tree/main" -%% click C href "https://github.com/stdlib-js/utils-async-while/tree/production" -%% click D href "https://github.com/stdlib-js/utils-async-while/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-async-while/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-async-while/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/async/while -[production-url]: https://github.com/stdlib-js/utils-async-while/tree/production -[deno-url]: https://github.com/stdlib-js/utils-async-while/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-async-while/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-async-while/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 efdafdf..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import whileAsync from '../docs/types/index'; -export = whileAsync; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 159efee..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var v=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var m=v(function(p,g){ -var s=require('@stdlib/assert-is-function/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist');function c(t,r,e,o){var u,i;if(!s(t))throw new TypeError(l('1Rr3c',t));if(!s(r))throw new TypeError(l('1Rr2H',r));if(!s(e))throw new TypeError(l('1Rr3N',e));u=[],i=0,t(i,f);function f(a,n){if(a)return e(a);if(n)return r.call(o,i,h);u.length&&u.unshift(null),e.apply(null,u)}function h(a){var n;if(a)return e(a);if(i+=1,arguments.length>1)for(u=new Array(arguments.length-1),n=1;n 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = whileAsync;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Invoke a function while a test condition is true.\n*\n* @module @stdlib/utils-async-while\n*\n* @example\n* var whileAsync = require( '@stdlib/utils-async-while' );\n*\n* function predicate( i, clbk ) {\n* clbk( null, i < 5 );\n* }\n*\n* function fcn( i, next ) {\n* setTimeout( onTimeout, i );\n* function onTimeout() {\n* console.log( 'beep: %d', i );\n* next();\n* }\n* }\n*\n* function done( error ) {\n* if ( error ) {\n* throw error;\n* }\n* }\n*\n* whileAsync( predicate, fcn, done );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAS,QAAS,uBAAwB,EAqC9C,SAASC,EAAYC,EAAWC,EAAKC,EAAMC,EAAU,CACpD,IAAIC,EACAC,EACJ,GAAK,CAACR,EAAYG,CAAU,EAC3B,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAU,CAAE,EAE/G,GAAK,CAACH,EAAYI,CAAI,EACrB,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAI,CAAE,EAE1G,GAAK,CAACJ,EAAYK,CAAK,EACtB,MAAM,IAAI,UAAWJ,EAAQ,oEAAqEI,CAAK,CAAE,EAE1GE,EAAO,CAAC,EACRC,EAAM,EACNL,EAAWK,EAAKC,CAAY,EAU5B,SAASA,EAAaC,EAAOC,EAAS,CACrC,GAAKD,EACJ,OAAOL,EAAMK,CAAM,EAEpB,GAAKC,EACJ,OAAOP,EAAI,KAAME,EAASE,EAAKI,CAAK,EAEhCL,EAAK,QACTA,EAAK,QAAS,IAAK,EAEpBF,EAAK,MAAO,KAAME,CAAK,CACxB,CAUA,SAASK,EAAMF,EAAQ,CACtB,IAAIG,EACJ,GAAKH,EACJ,OAAOL,EAAMK,CAAM,EAKpB,GAHAF,GAAO,EAGF,UAAU,OAAS,EAEvB,IADAD,EAAO,IAAI,MAAO,UAAU,OAAO,CAAE,EAC/BM,EAAI,EAAGA,EAAI,UAAU,OAAQA,IAClCN,EAAMM,EAAE,CAAE,EAAI,UAAWA,CAAE,EAI7BV,EAAWK,EAAKC,CAAY,CAC7B,CACD,CAKAV,EAAO,QAAUG,IC5EjB,IAAIY,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "format", "whileAsync", "predicate", "fcn", "done", "thisArg", "args", "idx", "onPredicate", "error", "result", "next", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index d7ca8c9..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,72 +0,0 @@ - -{{alias}}( predicate, fcn, done[, thisArg] ) - Invokes a function while a test condition is true. - - The predicate function is provided two arguments: - - - `i`: iteration number (starting from zero) - - `clbk`: a callback indicating whether to invoke `fcn` - - The `clbk` function accepts two arguments: - - - `error`: error argument - - `bool`: test result - - If the test result is truthy, the function invokes `fcn`; otherwise, the - function invokes the `done` callback. - - The function to invoke is provided two arguments: - - - `i`: iteration number (starting from zero) - - `next`: a callback which must be invoked before proceeding to the next - iteration - - The first argument of the `next` callback is an `error` argument. If `fcn` - calls the `next` callback with a truthy `error` argument, the function - suspends execution and immediately calls the `done` callback for subsequent - `error` handling. - - The `done` callback is invoked with an `error` argument and any arguments - passed to the final `next` callback. - - Execution is *not* guaranteed to be asynchronous. To guarantee asynchrony, - wrap the `done` callback in a function which either executes at the end of - the current stack (e.g., `nextTick`) or during a subsequent turn of the - event loop (e.g., `setImmediate`, `setTimeout`). - - Parameters - ---------- - predicate: Function - The predicate function which indicates whether to continue invoking a - function. - - fcn: Function - The function to invoke. - - done: Function - Callback to invoke upon completion. - - thisArg: any (optional) - Execution context for the invoked function. - - Examples - -------- - > function predicate( i, clbk ) { clbk( null, i < 5 ); }; - > function fcn( i, next ) { - ... setTimeout( onTimeout, i ); - ... function onTimeout() { - ... next( null, 'boop'+i ); - ... } - ... }; - > function done( error, result ) { - ... if ( error ) { - ... throw error; - ... } - ... console.log( result ); - ... }; - > {{alias}}( predicate, fcn, done ) - boop: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4a543d9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,83 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 whileAsync = require( './index' ); - -const fcn = ( i: number, next: Function ): void => { - if ( i === void 0 ) { - throw new Error( '`i` is missing.' ); - } - next(); -}; - -const predicate = ( i: number, clbk: Function ): void => { - clbk( null, i < 5 ); -}; - -const done = ( error: Error | null ): void => { - if ( error ) { - throw error; - } -}; - - -// TESTS // - -// The function returns void... -{ - whileAsync( predicate, fcn, done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a predicate function... -{ - whileAsync( 2, fcn, done ); // $ExpectError - whileAsync( false, fcn, done ); // $ExpectError - whileAsync( true, fcn, done ); // $ExpectError - whileAsync( 'abc', fcn, done ); // $ExpectError - whileAsync( {}, fcn, done ); // $ExpectError - whileAsync( [], fcn, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function having a supported signature... -{ - whileAsync( predicate, 2, done ); // $ExpectError - whileAsync( predicate, false, done ); // $ExpectError - whileAsync( predicate, true, done ); // $ExpectError - whileAsync( predicate, 'abc', done ); // $ExpectError - whileAsync( predicate, {}, done ); // $ExpectError - whileAsync( predicate, [], done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a done callback argument which is not a function having a supported signature... -{ - whileAsync( predicate, fcn, 2 ); // $ExpectError - whileAsync( predicate, fcn, false ); // $ExpectError - whileAsync( predicate, fcn, true ); // $ExpectError - whileAsync( predicate, fcn, 'abc' ); // $ExpectError - whileAsync( predicate, fcn, {} ); // $ExpectError - whileAsync( predicate, fcn, [] ); // $ExpectError - whileAsync( predicate, fcn, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - whileAsync(); // $ExpectError - whileAsync( predicate ); // $ExpectError - whileAsync( predicate, fcn ); // $ExpectError - whileAsync( predicate, fcn, done, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a6af668..0000000 --- a/examples/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var repeatString = require( '@stdlib/string-repeat' ); -var whileAsync = require( './../lib' ); - -function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } -} - -function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, repeatString( 'beep', i+1 ) ); - } -} - -function done( error, result ) { - if ( error ) { - throw error; - } - console.log( result ); -} - -whileAsync( predicate, fcn, done ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..3418902 --- /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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function r(r,e,i,s){var u,a;if(!n(r))throw new TypeError(t("invalid argument. First argument must be a function. Value: `%s`.",r));if(!n(e))throw new TypeError(t("invalid argument. Second argument must be a function. Value: `%s`.",e));if(!n(i))throw new TypeError(t("invalid argument. Third argument must be a function. Value: `%s`.",i));function l(n,t){return n?i(n):t?e.call(s,a,o):(u.length&&u.unshift(null),void i.apply(null,u))}function o(n){var t;if(n)return i(n);if(a+=1,arguments.length>1)for(u=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;qLA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,oEAAqER,IAEnG,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,qEAAsEP,IAEpG,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,oEAAqEN,IAcnG,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a13bd4..0000000 --- a/lib/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Invoke a function while a test condition is true. -* -* @module @stdlib/utils-async-while -* -* @example -* var whileAsync = require( '@stdlib/utils-async-while' ); -* -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 1dafc2a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,128 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); - - -// MAIN // - -/** -* Invokes a function while a test condition is true. -* -* @param {Function} predicate - function which indicates whether to continue invoking a function -* @param {Function} fcn - function to invoke -* @param {Callback} done - callback to invoke upon completion -* @param {*} [thisArg] - execution context for the invoked function -* @throws {TypeError} first argument must be a function -* @throws {TypeError} second argument must be a function -* @throws {TypeError} third argument must be a function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -function whileAsync( predicate, fcn, done, thisArg ) { - var args; - var idx; - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); - } - if ( !isFunction( done ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', done ) ); - } - args = []; - idx = 0; - predicate( idx, onPredicate ); - - /** - * Callback invoked upon a predicate result. - * - * @private - * @param {(Error|null)} error - error object - * @param {boolean} result - predicate result - * @returns {void} - */ - function onPredicate( error, result ) { - if ( error ) { - return done( error ); - } - if ( result ) { - return fcn.call( thisArg, idx, next ); - } - if ( args.length ) { - args.unshift( null ); // error argument - } - done.apply( null, args ); - } - - /** - * Callback invoked upon completion of a provided function. - * - * @private - * @param {(Error|null)} error - error object - * @param {...*} results - function results - * @returns {void} - */ - function next( error ) { - var i; - if ( error ) { - return done( error ); - } - idx += 1; - - // Cache the most recent results... - if ( arguments.length > 1 ) { - args = new Array( arguments.length-1 ); - for ( i = 1; i < arguments.length; i++ ) { - args[ i-1 ] = arguments[ i ]; - } - } - // Run the test condition: - predicate( idx, onPredicate ); - } -} - - -// EXPORTS // - -module.exports = whileAsync; diff --git a/package.json b/package.json index f1ad12e..751474c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Invoke a function while a test condition is true.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,35 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/math-base-assert-is-nan": "^0.1.1", - "@stdlib/random-base-randu": "^0.1.0", - "@stdlib/string-repeat": "^0.1.0", - "@stdlib/utils-noop": "^0.1.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.1.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..7c76e1a --- /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 78d0688..0000000 --- a/test/test.js +++ /dev/null @@ -1,328 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 whileAsync = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof whileAsync, 'function', 'main export is a function' ); - t.end(); -}); - -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() { - whileAsync( value, noop, 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() { - whileAsync( noop, value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a callback 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() { - whileAsync( noop, noop, value ); - }; - } -}); - -tape( 'while a test condition is true, the function invokes a provided function', function test( t ) { - var indices1 = [ 0, 1, 2, 3, 4, 5 ]; - var indices2 = [ 0, 1, 2, 3, 4 ]; - var j = -1; - var k = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices1[ j ], 'provides expected value' ); - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - k += 1; - t.strictEqual( i, indices2[ k ], 'provides expected value' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'while a test condition is true, the function invokes a provided function (always false)', function test( t ) { - var indices = [ 0 ]; - var j = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices[ j ], 'provides expected value' ); - clbk( null, false ); - } - - function fcn( i, next ) { - t.fail( 'should never be invoked' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx = { - 'count': 0 - }; - - whileAsync( predicate, fcn, done, ctx ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - this.count += 1; // eslint-disable-line no-invalid-this - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( ctx.count, 5, 'updates context' ); - t.end(); - } -}); - -tape( 'the function provides any results to a `done` callback', function test( t ) { - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, 'beep'+i, 'boop'+i, 'woot'+i ); - } - } - - function done( error, str1, str2, str3 ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( str1, 'beep4', 'returns expected value' ); - t.strictEqual( str2, 'boop4', 'returns expected value' ); - t.strictEqual( str3, 'woot4', 'returns expected value' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the predicate function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - if ( i === 1 ) { - return clbk( new Error( 'beep' ) ); - } - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 2, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the provided function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - if ( i === 2 ) { - return next( new Error( 'boop' ) ); - } - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 3, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'the function does not guarantee asynchronous execution', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - k = 1; - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - next(); - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( k, 0, 'releases the zalgo' ); - t.end(); - } -}); From 33b9be4493840266557f212965ae9e1a142df6a8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 01:42:23 +0000 Subject: [PATCH 084/143] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a45fa9c..f1ad12e 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ }, "dependencies": { "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/string-format": "^0.1.1" + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/math-base-assert-is-nan": "^0.1.1", From 77bed09a398e04831eefbc212f5ca459a9089f07 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 03:37:09 +0000 Subject: [PATCH 085/143] Remove files --- index.d.ts | 127 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6309 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 163e8ba..0000000 --- a/index.d.ts +++ /dev/null @@ -1,127 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Callback function. -*/ -type Nullary = () => void; - -/** -* Callback function. -* -* @param error - encountered error or null -*/ -type Unary = ( error: Error | null ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Binary = ( error: Error | null, bool: boolean ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Callback = Nullary | Unary | Binary; - -/** -* Callback invoked upon completion. -*/ -type DoneNullary = () => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -*/ -type DoneUnary = ( error: Error | null ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneBinary = ( error: Error | null, ...args: Array ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneCallback = DoneNullary | DoneUnary | DoneBinary; - -/** -* Checks whether an element in a collection passes a test. -* -* @param i - iteration number (starting from one) -* @param clbk - a callback indicating whether to invoke `fcn` -*/ -type Predicate = ( i: number, clbk: Callback ) => void; - -/** -* Invoked function. -* -* @param i - iteration number (starting from zero) -* @param next - a callback which must be invoked before proceeding to the next iteration -*/ -type Fcn = ( i: number, next: Function ) => void; - -/** -* Invokes a function while a test condition is true. -* -* @param predicate - function which indicates whether to continue invoking a function -* @param fcn - function to invoke -* @param done - callback to invoke upon completion -* @param thisArg - execution context for the invoked function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -declare function whileAsync( predicate: Predicate, fcn: Fcn, done: DoneCallback, thisArg?: any ): void; - - -// EXPORTS // - -export = whileAsync; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 3418902..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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function r(r,e,i,s){var u,a;if(!n(r))throw new TypeError(t("invalid argument. First argument must be a function. Value: `%s`.",r));if(!n(e))throw new TypeError(t("invalid argument. Second argument must be a function. Value: `%s`.",e));if(!n(i))throw new TypeError(t("invalid argument. Third argument must be a function. Value: `%s`.",i));function l(n,t){return n?i(n):t?e.call(s,a,o):(u.length&&u.unshift(null),void i.apply(null,u))}function o(n){var t;if(n)return i(n);if(a+=1,arguments.length>1)for(u=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;qLA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,oEAAqER,IAEnG,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,qEAAsEP,IAEpG,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,oEAAqEN,IAcnG,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 7c76e1a..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 8b0ca587e068f655d704471a179bdb0fb96b25ca Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 03:37:31 +0000 Subject: [PATCH 086/143] 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 | 105 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 72 - docs/types/test.ts | 83 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 57 - lib/main.js | 128 - package.json | 56 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 328 -- 43 files changed, 6202 insertions(+), 4172 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 (100%) 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 d07fee1..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-02-01T01:08:40.904Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 0f8dec8..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/async/while) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 9633c26..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/async/while) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 f056373..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: '8 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' - # 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 + + ```
@@ -292,7 +283,7 @@ whileAsync( predicate, fcn, done ); ## 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]. @@ -357,13 +348,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until +[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until/tree/esm -[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while +[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while/tree/esm -[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until +[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until/tree/esm -[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while +[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while/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 7c83acf..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var whileAsync = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); - -bench( pkg+'::sync_predicate', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2c3ed87..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/async/while" -%% click B href "https://github.com/stdlib-js/utils-async-while/tree/main" -%% click C href "https://github.com/stdlib-js/utils-async-while/tree/production" -%% click D href "https://github.com/stdlib-js/utils-async-while/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-async-while/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-async-while/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/async/while -[production-url]: https://github.com/stdlib-js/utils-async-while/tree/production -[deno-url]: https://github.com/stdlib-js/utils-async-while/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-async-while/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-async-while/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-async-while/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-async-while/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-async-while/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 efdafdf..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import whileAsync from '../docs/types/index'; -export = whileAsync; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 159efee..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var v=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var m=v(function(p,g){ -var s=require('@stdlib/assert-is-function/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist');function c(t,r,e,o){var u,i;if(!s(t))throw new TypeError(l('1Rr3c',t));if(!s(r))throw new TypeError(l('1Rr2H',r));if(!s(e))throw new TypeError(l('1Rr3N',e));u=[],i=0,t(i,f);function f(a,n){if(a)return e(a);if(n)return r.call(o,i,h);u.length&&u.unshift(null),e.apply(null,u)}function h(a){var n;if(a)return e(a);if(i+=1,arguments.length>1)for(u=new Array(arguments.length-1),n=1;n 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = whileAsync;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Invoke a function while a test condition is true.\n*\n* @module @stdlib/utils-async-while\n*\n* @example\n* var whileAsync = require( '@stdlib/utils-async-while' );\n*\n* function predicate( i, clbk ) {\n* clbk( null, i < 5 );\n* }\n*\n* function fcn( i, next ) {\n* setTimeout( onTimeout, i );\n* function onTimeout() {\n* console.log( 'beep: %d', i );\n* next();\n* }\n* }\n*\n* function done( error ) {\n* if ( error ) {\n* throw error;\n* }\n* }\n*\n* whileAsync( predicate, fcn, done );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAS,QAAS,uBAAwB,EAqC9C,SAASC,EAAYC,EAAWC,EAAKC,EAAMC,EAAU,CACpD,IAAIC,EACAC,EACJ,GAAK,CAACR,EAAYG,CAAU,EAC3B,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAU,CAAE,EAE/G,GAAK,CAACH,EAAYI,CAAI,EACrB,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAI,CAAE,EAE1G,GAAK,CAACJ,EAAYK,CAAK,EACtB,MAAM,IAAI,UAAWJ,EAAQ,oEAAqEI,CAAK,CAAE,EAE1GE,EAAO,CAAC,EACRC,EAAM,EACNL,EAAWK,EAAKC,CAAY,EAU5B,SAASA,EAAaC,EAAOC,EAAS,CACrC,GAAKD,EACJ,OAAOL,EAAMK,CAAM,EAEpB,GAAKC,EACJ,OAAOP,EAAI,KAAME,EAASE,EAAKI,CAAK,EAEhCL,EAAK,QACTA,EAAK,QAAS,IAAK,EAEpBF,EAAK,MAAO,KAAME,CAAK,CACxB,CAUA,SAASK,EAAMF,EAAQ,CACtB,IAAIG,EACJ,GAAKH,EACJ,OAAOL,EAAMK,CAAM,EAKpB,GAHAF,GAAO,EAGF,UAAU,OAAS,EAEvB,IADAD,EAAO,IAAI,MAAO,UAAU,OAAO,CAAE,EAC/BM,EAAI,EAAGA,EAAI,UAAU,OAAQA,IAClCN,EAAMM,EAAE,CAAE,EAAI,UAAWA,CAAE,EAI7BV,EAAWK,EAAKC,CAAY,CAC7B,CACD,CAKAV,EAAO,QAAUG,IC5EjB,IAAIY,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "format", "whileAsync", "predicate", "fcn", "done", "thisArg", "args", "idx", "onPredicate", "error", "result", "next", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index d7ca8c9..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,72 +0,0 @@ - -{{alias}}( predicate, fcn, done[, thisArg] ) - Invokes a function while a test condition is true. - - The predicate function is provided two arguments: - - - `i`: iteration number (starting from zero) - - `clbk`: a callback indicating whether to invoke `fcn` - - The `clbk` function accepts two arguments: - - - `error`: error argument - - `bool`: test result - - If the test result is truthy, the function invokes `fcn`; otherwise, the - function invokes the `done` callback. - - The function to invoke is provided two arguments: - - - `i`: iteration number (starting from zero) - - `next`: a callback which must be invoked before proceeding to the next - iteration - - The first argument of the `next` callback is an `error` argument. If `fcn` - calls the `next` callback with a truthy `error` argument, the function - suspends execution and immediately calls the `done` callback for subsequent - `error` handling. - - The `done` callback is invoked with an `error` argument and any arguments - passed to the final `next` callback. - - Execution is *not* guaranteed to be asynchronous. To guarantee asynchrony, - wrap the `done` callback in a function which either executes at the end of - the current stack (e.g., `nextTick`) or during a subsequent turn of the - event loop (e.g., `setImmediate`, `setTimeout`). - - Parameters - ---------- - predicate: Function - The predicate function which indicates whether to continue invoking a - function. - - fcn: Function - The function to invoke. - - done: Function - Callback to invoke upon completion. - - thisArg: any (optional) - Execution context for the invoked function. - - Examples - -------- - > function predicate( i, clbk ) { clbk( null, i < 5 ); }; - > function fcn( i, next ) { - ... setTimeout( onTimeout, i ); - ... function onTimeout() { - ... next( null, 'boop'+i ); - ... } - ... }; - > function done( error, result ) { - ... if ( error ) { - ... throw error; - ... } - ... console.log( result ); - ... }; - > {{alias}}( predicate, fcn, done ) - boop: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4a543d9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,83 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 whileAsync = require( './index' ); - -const fcn = ( i: number, next: Function ): void => { - if ( i === void 0 ) { - throw new Error( '`i` is missing.' ); - } - next(); -}; - -const predicate = ( i: number, clbk: Function ): void => { - clbk( null, i < 5 ); -}; - -const done = ( error: Error | null ): void => { - if ( error ) { - throw error; - } -}; - - -// TESTS // - -// The function returns void... -{ - whileAsync( predicate, fcn, done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a predicate function... -{ - whileAsync( 2, fcn, done ); // $ExpectError - whileAsync( false, fcn, done ); // $ExpectError - whileAsync( true, fcn, done ); // $ExpectError - whileAsync( 'abc', fcn, done ); // $ExpectError - whileAsync( {}, fcn, done ); // $ExpectError - whileAsync( [], fcn, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function having a supported signature... -{ - whileAsync( predicate, 2, done ); // $ExpectError - whileAsync( predicate, false, done ); // $ExpectError - whileAsync( predicate, true, done ); // $ExpectError - whileAsync( predicate, 'abc', done ); // $ExpectError - whileAsync( predicate, {}, done ); // $ExpectError - whileAsync( predicate, [], done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a done callback argument which is not a function having a supported signature... -{ - whileAsync( predicate, fcn, 2 ); // $ExpectError - whileAsync( predicate, fcn, false ); // $ExpectError - whileAsync( predicate, fcn, true ); // $ExpectError - whileAsync( predicate, fcn, 'abc' ); // $ExpectError - whileAsync( predicate, fcn, {} ); // $ExpectError - whileAsync( predicate, fcn, [] ); // $ExpectError - whileAsync( predicate, fcn, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - whileAsync(); // $ExpectError - whileAsync( predicate ); // $ExpectError - whileAsync( predicate, fcn ); // $ExpectError - whileAsync( predicate, fcn, done, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a6af668..0000000 --- a/examples/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var repeatString = require( '@stdlib/string-repeat' ); -var whileAsync = require( './../lib' ); - -function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } -} - -function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, repeatString( 'beep', i+1 ) ); - } -} - -function done( error, result ) { - if ( error ) { - throw error; - } - console.log( result ); -} - -whileAsync( predicate, fcn, done ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..3418902 --- /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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function r(r,e,i,s){var u,a;if(!n(r))throw new TypeError(t("invalid argument. First argument must be a function. Value: `%s`.",r));if(!n(e))throw new TypeError(t("invalid argument. Second argument must be a function. Value: `%s`.",e));if(!n(i))throw new TypeError(t("invalid argument. Third argument must be a function. Value: `%s`.",i));function l(n,t){return n?i(n):t?e.call(s,a,o):(u.length&&u.unshift(null),void i.apply(null,u))}function o(n){var t;if(n)return i(n);if(a+=1,arguments.length>1)for(u=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;qLA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,oEAAqER,IAEnG,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,qEAAsEP,IAEpG,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,oEAAqEN,IAcnG,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a13bd4..0000000 --- a/lib/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Invoke a function while a test condition is true. -* -* @module @stdlib/utils-async-while -* -* @example -* var whileAsync = require( '@stdlib/utils-async-while' ); -* -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 1dafc2a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,128 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); - - -// MAIN // - -/** -* Invokes a function while a test condition is true. -* -* @param {Function} predicate - function which indicates whether to continue invoking a function -* @param {Function} fcn - function to invoke -* @param {Callback} done - callback to invoke upon completion -* @param {*} [thisArg] - execution context for the invoked function -* @throws {TypeError} first argument must be a function -* @throws {TypeError} second argument must be a function -* @throws {TypeError} third argument must be a function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -function whileAsync( predicate, fcn, done, thisArg ) { - var args; - var idx; - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); - } - if ( !isFunction( done ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', done ) ); - } - args = []; - idx = 0; - predicate( idx, onPredicate ); - - /** - * Callback invoked upon a predicate result. - * - * @private - * @param {(Error|null)} error - error object - * @param {boolean} result - predicate result - * @returns {void} - */ - function onPredicate( error, result ) { - if ( error ) { - return done( error ); - } - if ( result ) { - return fcn.call( thisArg, idx, next ); - } - if ( args.length ) { - args.unshift( null ); // error argument - } - done.apply( null, args ); - } - - /** - * Callback invoked upon completion of a provided function. - * - * @private - * @param {(Error|null)} error - error object - * @param {...*} results - function results - * @returns {void} - */ - function next( error ) { - var i; - if ( error ) { - return done( error ); - } - idx += 1; - - // Cache the most recent results... - if ( arguments.length > 1 ) { - args = new Array( arguments.length-1 ); - for ( i = 1; i < arguments.length; i++ ) { - args[ i-1 ] = arguments[ i ]; - } - } - // Run the test condition: - predicate( idx, onPredicate ); - } -} - - -// EXPORTS // - -module.exports = whileAsync; diff --git a/package.json b/package.json index f1ad12e..751474c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Invoke a function while a test condition is true.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,35 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/math-base-assert-is-nan": "^0.1.1", - "@stdlib/random-base-randu": "^0.1.0", - "@stdlib/string-repeat": "^0.1.0", - "@stdlib/utils-noop": "^0.1.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.1.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b3eb1fe --- /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 78d0688..0000000 --- a/test/test.js +++ /dev/null @@ -1,328 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 whileAsync = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof whileAsync, 'function', 'main export is a function' ); - t.end(); -}); - -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() { - whileAsync( value, noop, 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() { - whileAsync( noop, value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a callback 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() { - whileAsync( noop, noop, value ); - }; - } -}); - -tape( 'while a test condition is true, the function invokes a provided function', function test( t ) { - var indices1 = [ 0, 1, 2, 3, 4, 5 ]; - var indices2 = [ 0, 1, 2, 3, 4 ]; - var j = -1; - var k = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices1[ j ], 'provides expected value' ); - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - k += 1; - t.strictEqual( i, indices2[ k ], 'provides expected value' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'while a test condition is true, the function invokes a provided function (always false)', function test( t ) { - var indices = [ 0 ]; - var j = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices[ j ], 'provides expected value' ); - clbk( null, false ); - } - - function fcn( i, next ) { - t.fail( 'should never be invoked' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx = { - 'count': 0 - }; - - whileAsync( predicate, fcn, done, ctx ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - this.count += 1; // eslint-disable-line no-invalid-this - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( ctx.count, 5, 'updates context' ); - t.end(); - } -}); - -tape( 'the function provides any results to a `done` callback', function test( t ) { - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, 'beep'+i, 'boop'+i, 'woot'+i ); - } - } - - function done( error, str1, str2, str3 ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( str1, 'beep4', 'returns expected value' ); - t.strictEqual( str2, 'boop4', 'returns expected value' ); - t.strictEqual( str3, 'woot4', 'returns expected value' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the predicate function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - if ( i === 1 ) { - return clbk( new Error( 'beep' ) ); - } - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 2, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the provided function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - if ( i === 2 ) { - return next( new Error( 'boop' ) ); - } - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 3, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'the function does not guarantee asynchronous execution', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - k = 1; - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - next(); - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( k, 0, 'releases the zalgo' ); - t.end(); - } -}); From 95927a8a521d81750972751f8d6ee3420dfb1e48 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 04:30:10 +0000 Subject: [PATCH 087/143] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 197b63a..947f798 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ }, "dependencies": { "@stdlib/assert-is-function": "^0.2.0", - "@stdlib/string-format": "^0.2.0" + "@stdlib/error-tools-fmtprodmsg": "^0.2.0" }, "devDependencies": { "@stdlib/math-base-assert-is-nan": "^0.1.1", From e7fc5927d3e7a4456e876bcb04bdf13563688c30 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 06:00:13 +0000 Subject: [PATCH 088/143] Remove files --- index.d.ts | 127 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6309 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 163e8ba..0000000 --- a/index.d.ts +++ /dev/null @@ -1,127 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Callback function. -*/ -type Nullary = () => void; - -/** -* Callback function. -* -* @param error - encountered error or null -*/ -type Unary = ( error: Error | null ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Binary = ( error: Error | null, bool: boolean ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Callback = Nullary | Unary | Binary; - -/** -* Callback invoked upon completion. -*/ -type DoneNullary = () => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -*/ -type DoneUnary = ( error: Error | null ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneBinary = ( error: Error | null, ...args: Array ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneCallback = DoneNullary | DoneUnary | DoneBinary; - -/** -* Checks whether an element in a collection passes a test. -* -* @param i - iteration number (starting from one) -* @param clbk - a callback indicating whether to invoke `fcn` -*/ -type Predicate = ( i: number, clbk: Callback ) => void; - -/** -* Invoked function. -* -* @param i - iteration number (starting from zero) -* @param next - a callback which must be invoked before proceeding to the next iteration -*/ -type Fcn = ( i: number, next: Function ) => void; - -/** -* Invokes a function while a test condition is true. -* -* @param predicate - function which indicates whether to continue invoking a function -* @param fcn - function to invoke -* @param done - callback to invoke upon completion -* @param thisArg - execution context for the invoked function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -declare function whileAsync( predicate: Predicate, fcn: Fcn, done: DoneCallback, thisArg?: any ): void; - - -// EXPORTS // - -export = whileAsync; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 3418902..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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function r(r,e,i,s){var u,a;if(!n(r))throw new TypeError(t("invalid argument. First argument must be a function. Value: `%s`.",r));if(!n(e))throw new TypeError(t("invalid argument. Second argument must be a function. Value: `%s`.",e));if(!n(i))throw new TypeError(t("invalid argument. Third argument must be a function. Value: `%s`.",i));function l(n,t){return n?i(n):t?e.call(s,a,o):(u.length&&u.unshift(null),void i.apply(null,u))}function o(n){var t;if(n)return i(n);if(a+=1,arguments.length>1)for(u=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;qLA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,oEAAqER,IAEnG,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,qEAAsEP,IAEpG,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,oEAAqEN,IAcnG,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b3eb1fe..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 77d8f71de5c229a25f527d0470e8a09ac0ae0ca9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 06:00:40 +0000 Subject: [PATCH 089/143] 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 | 105 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 72 - docs/types/test.ts | 83 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 57 - lib/main.js | 128 - package.json | 56 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 328 -- 42 files changed, 6202 insertions(+), 4175 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 (100%) 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 0f8dec8..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/async/while) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 9633c26..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/async/while) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 2a349e4..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: '8 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' - # 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 + + ```
@@ -292,7 +283,7 @@ whileAsync( predicate, fcn, done ); ## 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]. @@ -357,13 +348,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until +[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until/tree/esm -[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while +[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while/tree/esm -[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until +[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until/tree/esm -[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while +[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while/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 7c83acf..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var whileAsync = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); - -bench( pkg+'::sync_predicate', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2c3ed87..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/async/while" -%% click B href "https://github.com/stdlib-js/utils-async-while/tree/main" -%% click C href "https://github.com/stdlib-js/utils-async-while/tree/production" -%% click D href "https://github.com/stdlib-js/utils-async-while/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-async-while/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-async-while/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/async/while -[production-url]: https://github.com/stdlib-js/utils-async-while/tree/production -[deno-url]: https://github.com/stdlib-js/utils-async-while/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-async-while/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-async-while/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-async-while/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-async-while/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-async-while/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 efdafdf..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import whileAsync from '../docs/types/index'; -export = whileAsync; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 159efee..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var v=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var m=v(function(p,g){ -var s=require('@stdlib/assert-is-function/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist');function c(t,r,e,o){var u,i;if(!s(t))throw new TypeError(l('1Rr3c',t));if(!s(r))throw new TypeError(l('1Rr2H',r));if(!s(e))throw new TypeError(l('1Rr3N',e));u=[],i=0,t(i,f);function f(a,n){if(a)return e(a);if(n)return r.call(o,i,h);u.length&&u.unshift(null),e.apply(null,u)}function h(a){var n;if(a)return e(a);if(i+=1,arguments.length>1)for(u=new Array(arguments.length-1),n=1;n 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = whileAsync;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Invoke a function while a test condition is true.\n*\n* @module @stdlib/utils-async-while\n*\n* @example\n* var whileAsync = require( '@stdlib/utils-async-while' );\n*\n* function predicate( i, clbk ) {\n* clbk( null, i < 5 );\n* }\n*\n* function fcn( i, next ) {\n* setTimeout( onTimeout, i );\n* function onTimeout() {\n* console.log( 'beep: %d', i );\n* next();\n* }\n* }\n*\n* function done( error ) {\n* if ( error ) {\n* throw error;\n* }\n* }\n*\n* whileAsync( predicate, fcn, done );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAS,QAAS,uBAAwB,EAqC9C,SAASC,EAAYC,EAAWC,EAAKC,EAAMC,EAAU,CACpD,IAAIC,EACAC,EACJ,GAAK,CAACR,EAAYG,CAAU,EAC3B,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAU,CAAE,EAE/G,GAAK,CAACH,EAAYI,CAAI,EACrB,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAI,CAAE,EAE1G,GAAK,CAACJ,EAAYK,CAAK,EACtB,MAAM,IAAI,UAAWJ,EAAQ,oEAAqEI,CAAK,CAAE,EAE1GE,EAAO,CAAC,EACRC,EAAM,EACNL,EAAWK,EAAKC,CAAY,EAU5B,SAASA,EAAaC,EAAOC,EAAS,CACrC,GAAKD,EACJ,OAAOL,EAAMK,CAAM,EAEpB,GAAKC,EACJ,OAAOP,EAAI,KAAME,EAASE,EAAKI,CAAK,EAEhCL,EAAK,QACTA,EAAK,QAAS,IAAK,EAEpBF,EAAK,MAAO,KAAME,CAAK,CACxB,CAUA,SAASK,EAAMF,EAAQ,CACtB,IAAIG,EACJ,GAAKH,EACJ,OAAOL,EAAMK,CAAM,EAKpB,GAHAF,GAAO,EAGF,UAAU,OAAS,EAEvB,IADAD,EAAO,IAAI,MAAO,UAAU,OAAO,CAAE,EAC/BM,EAAI,EAAGA,EAAI,UAAU,OAAQA,IAClCN,EAAMM,EAAE,CAAE,EAAI,UAAWA,CAAE,EAI7BV,EAAWK,EAAKC,CAAY,CAC7B,CACD,CAKAV,EAAO,QAAUG,IC5EjB,IAAIY,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "format", "whileAsync", "predicate", "fcn", "done", "thisArg", "args", "idx", "onPredicate", "error", "result", "next", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index d7ca8c9..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,72 +0,0 @@ - -{{alias}}( predicate, fcn, done[, thisArg] ) - Invokes a function while a test condition is true. - - The predicate function is provided two arguments: - - - `i`: iteration number (starting from zero) - - `clbk`: a callback indicating whether to invoke `fcn` - - The `clbk` function accepts two arguments: - - - `error`: error argument - - `bool`: test result - - If the test result is truthy, the function invokes `fcn`; otherwise, the - function invokes the `done` callback. - - The function to invoke is provided two arguments: - - - `i`: iteration number (starting from zero) - - `next`: a callback which must be invoked before proceeding to the next - iteration - - The first argument of the `next` callback is an `error` argument. If `fcn` - calls the `next` callback with a truthy `error` argument, the function - suspends execution and immediately calls the `done` callback for subsequent - `error` handling. - - The `done` callback is invoked with an `error` argument and any arguments - passed to the final `next` callback. - - Execution is *not* guaranteed to be asynchronous. To guarantee asynchrony, - wrap the `done` callback in a function which either executes at the end of - the current stack (e.g., `nextTick`) or during a subsequent turn of the - event loop (e.g., `setImmediate`, `setTimeout`). - - Parameters - ---------- - predicate: Function - The predicate function which indicates whether to continue invoking a - function. - - fcn: Function - The function to invoke. - - done: Function - Callback to invoke upon completion. - - thisArg: any (optional) - Execution context for the invoked function. - - Examples - -------- - > function predicate( i, clbk ) { clbk( null, i < 5 ); }; - > function fcn( i, next ) { - ... setTimeout( onTimeout, i ); - ... function onTimeout() { - ... next( null, 'boop'+i ); - ... } - ... }; - > function done( error, result ) { - ... if ( error ) { - ... throw error; - ... } - ... console.log( result ); - ... }; - > {{alias}}( predicate, fcn, done ) - boop: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4a543d9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,83 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 whileAsync = require( './index' ); - -const fcn = ( i: number, next: Function ): void => { - if ( i === void 0 ) { - throw new Error( '`i` is missing.' ); - } - next(); -}; - -const predicate = ( i: number, clbk: Function ): void => { - clbk( null, i < 5 ); -}; - -const done = ( error: Error | null ): void => { - if ( error ) { - throw error; - } -}; - - -// TESTS // - -// The function returns void... -{ - whileAsync( predicate, fcn, done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a predicate function... -{ - whileAsync( 2, fcn, done ); // $ExpectError - whileAsync( false, fcn, done ); // $ExpectError - whileAsync( true, fcn, done ); // $ExpectError - whileAsync( 'abc', fcn, done ); // $ExpectError - whileAsync( {}, fcn, done ); // $ExpectError - whileAsync( [], fcn, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function having a supported signature... -{ - whileAsync( predicate, 2, done ); // $ExpectError - whileAsync( predicate, false, done ); // $ExpectError - whileAsync( predicate, true, done ); // $ExpectError - whileAsync( predicate, 'abc', done ); // $ExpectError - whileAsync( predicate, {}, done ); // $ExpectError - whileAsync( predicate, [], done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a done callback argument which is not a function having a supported signature... -{ - whileAsync( predicate, fcn, 2 ); // $ExpectError - whileAsync( predicate, fcn, false ); // $ExpectError - whileAsync( predicate, fcn, true ); // $ExpectError - whileAsync( predicate, fcn, 'abc' ); // $ExpectError - whileAsync( predicate, fcn, {} ); // $ExpectError - whileAsync( predicate, fcn, [] ); // $ExpectError - whileAsync( predicate, fcn, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - whileAsync(); // $ExpectError - whileAsync( predicate ); // $ExpectError - whileAsync( predicate, fcn ); // $ExpectError - whileAsync( predicate, fcn, done, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a6af668..0000000 --- a/examples/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var repeatString = require( '@stdlib/string-repeat' ); -var whileAsync = require( './../lib' ); - -function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } -} - -function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, repeatString( 'beep', i+1 ) ); - } -} - -function done( error, result ) { - if ( error ) { - throw error; - } - console.log( result ); -} - -whileAsync( predicate, fcn, done ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..3418902 --- /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 n from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function r(r,e,i,s){var u,a;if(!n(r))throw new TypeError(t("invalid argument. First argument must be a function. Value: `%s`.",r));if(!n(e))throw new TypeError(t("invalid argument. Second argument must be a function. Value: `%s`.",e));if(!n(i))throw new TypeError(t("invalid argument. Third argument must be a function. Value: `%s`.",i));function l(n,t){return n?i(n):t?e.call(s,a,o):(u.length&&u.unshift(null),void i.apply(null,u))}function o(n){var t;if(n)return i(n);if(a+=1,arguments.length>1)for(u=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;qLA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,oEAAqER,IAEnG,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,qEAAsEP,IAEpG,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,oEAAqEN,IAcnG,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a13bd4..0000000 --- a/lib/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Invoke a function while a test condition is true. -* -* @module @stdlib/utils-async-while -* -* @example -* var whileAsync = require( '@stdlib/utils-async-while' ); -* -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 1dafc2a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,128 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); - - -// MAIN // - -/** -* Invokes a function while a test condition is true. -* -* @param {Function} predicate - function which indicates whether to continue invoking a function -* @param {Function} fcn - function to invoke -* @param {Callback} done - callback to invoke upon completion -* @param {*} [thisArg] - execution context for the invoked function -* @throws {TypeError} first argument must be a function -* @throws {TypeError} second argument must be a function -* @throws {TypeError} third argument must be a function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -function whileAsync( predicate, fcn, done, thisArg ) { - var args; - var idx; - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); - } - if ( !isFunction( done ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', done ) ); - } - args = []; - idx = 0; - predicate( idx, onPredicate ); - - /** - * Callback invoked upon a predicate result. - * - * @private - * @param {(Error|null)} error - error object - * @param {boolean} result - predicate result - * @returns {void} - */ - function onPredicate( error, result ) { - if ( error ) { - return done( error ); - } - if ( result ) { - return fcn.call( thisArg, idx, next ); - } - if ( args.length ) { - args.unshift( null ); // error argument - } - done.apply( null, args ); - } - - /** - * Callback invoked upon completion of a provided function. - * - * @private - * @param {(Error|null)} error - error object - * @param {...*} results - function results - * @returns {void} - */ - function next( error ) { - var i; - if ( error ) { - return done( error ); - } - idx += 1; - - // Cache the most recent results... - if ( arguments.length > 1 ) { - args = new Array( arguments.length-1 ); - for ( i = 1; i < arguments.length; i++ ) { - args[ i-1 ] = arguments[ i ]; - } - } - // Run the test condition: - predicate( idx, onPredicate ); - } -} - - -// EXPORTS // - -module.exports = whileAsync; diff --git a/package.json b/package.json index 947f798..d617f4d 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.0", "description": "Invoke a function while a test condition is true.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,35 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.2.0", - "@stdlib/error-tools-fmtprodmsg": "^0.2.0" - }, - "devDependencies": { - "@stdlib/math-base-assert-is-nan": "^0.1.1", - "@stdlib/random-base-randu": "^0.1.0", - "@stdlib/string-repeat": "^0.1.0", - "@stdlib/utils-noop": "^0.2.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.1.2" - }, - "engines": { - "node": ">=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..b477709 --- /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 78d0688..0000000 --- a/test/test.js +++ /dev/null @@ -1,328 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 whileAsync = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof whileAsync, 'function', 'main export is a function' ); - t.end(); -}); - -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() { - whileAsync( value, noop, 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() { - whileAsync( noop, value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a callback 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() { - whileAsync( noop, noop, value ); - }; - } -}); - -tape( 'while a test condition is true, the function invokes a provided function', function test( t ) { - var indices1 = [ 0, 1, 2, 3, 4, 5 ]; - var indices2 = [ 0, 1, 2, 3, 4 ]; - var j = -1; - var k = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices1[ j ], 'provides expected value' ); - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - k += 1; - t.strictEqual( i, indices2[ k ], 'provides expected value' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'while a test condition is true, the function invokes a provided function (always false)', function test( t ) { - var indices = [ 0 ]; - var j = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices[ j ], 'provides expected value' ); - clbk( null, false ); - } - - function fcn( i, next ) { - t.fail( 'should never be invoked' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx = { - 'count': 0 - }; - - whileAsync( predicate, fcn, done, ctx ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - this.count += 1; // eslint-disable-line no-invalid-this - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( ctx.count, 5, 'updates context' ); - t.end(); - } -}); - -tape( 'the function provides any results to a `done` callback', function test( t ) { - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, 'beep'+i, 'boop'+i, 'woot'+i ); - } - } - - function done( error, str1, str2, str3 ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( str1, 'beep4', 'returns expected value' ); - t.strictEqual( str2, 'boop4', 'returns expected value' ); - t.strictEqual( str3, 'woot4', 'returns expected value' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the predicate function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - if ( i === 1 ) { - return clbk( new Error( 'beep' ) ); - } - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 2, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the provided function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - if ( i === 2 ) { - return next( new Error( 'boop' ) ); - } - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 3, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'the function does not guarantee asynchronous execution', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - k = 1; - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - next(); - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( k, 0, 'releases the zalgo' ); - t.end(); - } -}); From a4c4eb7e43ae87e6e063ef103c906d25aaa2b22d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 07:29:43 +0000 Subject: [PATCH 090/143] 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 185519a..fe277a6 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import whileAsync from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-async-while@esm/index.mjs'; +import whileAsync from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-async-while@v0.2.0-esm/index.mjs'; ``` #### whileAsync( predicate, fcn, done\[, thisArg ] ) @@ -215,7 +215,7 @@ function done( error ) { - - - - From cb7dfae1b1a19e015098ef4d0e2810a70cb6e83f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 22 Feb 2024 01:32:48 +0000 Subject: [PATCH 094/143] 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 | 105 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 72 - docs/types/test.ts | 83 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 57 - lib/main.js | 128 - package.json | 56 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 328 -- 42 files changed, 4867 insertions(+), 4169 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 (100%) 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 0f8dec8..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/async/while) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 9633c26..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/async/while) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 0bdf3fd..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: '8 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' - # 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 + + ```
@@ -292,7 +283,7 @@ whileAsync( predicate, fcn, done ); ## 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]. @@ -357,13 +348,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until +[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until/tree/esm -[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while +[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while/tree/esm -[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until +[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until/tree/esm -[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while +[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while/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 7c83acf..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var whileAsync = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); - -bench( pkg+'::sync_predicate', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2c3ed87..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/async/while" -%% click B href "https://github.com/stdlib-js/utils-async-while/tree/main" -%% click C href "https://github.com/stdlib-js/utils-async-while/tree/production" -%% click D href "https://github.com/stdlib-js/utils-async-while/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-async-while/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-async-while/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/async/while -[production-url]: https://github.com/stdlib-js/utils-async-while/tree/production -[deno-url]: https://github.com/stdlib-js/utils-async-while/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-async-while/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-async-while/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-async-while/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-async-while/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-async-while/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 efdafdf..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import whileAsync from '../docs/types/index'; -export = whileAsync; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 159efee..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var v=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var m=v(function(p,g){ -var s=require('@stdlib/assert-is-function/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist');function c(t,r,e,o){var u,i;if(!s(t))throw new TypeError(l('1Rr3c',t));if(!s(r))throw new TypeError(l('1Rr2H',r));if(!s(e))throw new TypeError(l('1Rr3N',e));u=[],i=0,t(i,f);function f(a,n){if(a)return e(a);if(n)return r.call(o,i,h);u.length&&u.unshift(null),e.apply(null,u)}function h(a){var n;if(a)return e(a);if(i+=1,arguments.length>1)for(u=new Array(arguments.length-1),n=1;n 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = whileAsync;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Invoke a function while a test condition is true.\n*\n* @module @stdlib/utils-async-while\n*\n* @example\n* var whileAsync = require( '@stdlib/utils-async-while' );\n*\n* function predicate( i, clbk ) {\n* clbk( null, i < 5 );\n* }\n*\n* function fcn( i, next ) {\n* setTimeout( onTimeout, i );\n* function onTimeout() {\n* console.log( 'beep: %d', i );\n* next();\n* }\n* }\n*\n* function done( error ) {\n* if ( error ) {\n* throw error;\n* }\n* }\n*\n* whileAsync( predicate, fcn, done );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAS,QAAS,uBAAwB,EAqC9C,SAASC,EAAYC,EAAWC,EAAKC,EAAMC,EAAU,CACpD,IAAIC,EACAC,EACJ,GAAK,CAACR,EAAYG,CAAU,EAC3B,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAU,CAAE,EAE/G,GAAK,CAACH,EAAYI,CAAI,EACrB,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAI,CAAE,EAE1G,GAAK,CAACJ,EAAYK,CAAK,EACtB,MAAM,IAAI,UAAWJ,EAAQ,oEAAqEI,CAAK,CAAE,EAE1GE,EAAO,CAAC,EACRC,EAAM,EACNL,EAAWK,EAAKC,CAAY,EAU5B,SAASA,EAAaC,EAAOC,EAAS,CACrC,GAAKD,EACJ,OAAOL,EAAMK,CAAM,EAEpB,GAAKC,EACJ,OAAOP,EAAI,KAAME,EAASE,EAAKI,CAAK,EAEhCL,EAAK,QACTA,EAAK,QAAS,IAAK,EAEpBF,EAAK,MAAO,KAAME,CAAK,CACxB,CAUA,SAASK,EAAMF,EAAQ,CACtB,IAAIG,EACJ,GAAKH,EACJ,OAAOL,EAAMK,CAAM,EAKpB,GAHAF,GAAO,EAGF,UAAU,OAAS,EAEvB,IADAD,EAAO,IAAI,MAAO,UAAU,OAAO,CAAE,EAC/BM,EAAI,EAAGA,EAAI,UAAU,OAAQA,IAClCN,EAAMM,EAAE,CAAE,EAAI,UAAWA,CAAE,EAI7BV,EAAWK,EAAKC,CAAY,CAC7B,CACD,CAKAV,EAAO,QAAUG,IC5EjB,IAAIY,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "format", "whileAsync", "predicate", "fcn", "done", "thisArg", "args", "idx", "onPredicate", "error", "result", "next", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index d7ca8c9..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,72 +0,0 @@ - -{{alias}}( predicate, fcn, done[, thisArg] ) - Invokes a function while a test condition is true. - - The predicate function is provided two arguments: - - - `i`: iteration number (starting from zero) - - `clbk`: a callback indicating whether to invoke `fcn` - - The `clbk` function accepts two arguments: - - - `error`: error argument - - `bool`: test result - - If the test result is truthy, the function invokes `fcn`; otherwise, the - function invokes the `done` callback. - - The function to invoke is provided two arguments: - - - `i`: iteration number (starting from zero) - - `next`: a callback which must be invoked before proceeding to the next - iteration - - The first argument of the `next` callback is an `error` argument. If `fcn` - calls the `next` callback with a truthy `error` argument, the function - suspends execution and immediately calls the `done` callback for subsequent - `error` handling. - - The `done` callback is invoked with an `error` argument and any arguments - passed to the final `next` callback. - - Execution is *not* guaranteed to be asynchronous. To guarantee asynchrony, - wrap the `done` callback in a function which either executes at the end of - the current stack (e.g., `nextTick`) or during a subsequent turn of the - event loop (e.g., `setImmediate`, `setTimeout`). - - Parameters - ---------- - predicate: Function - The predicate function which indicates whether to continue invoking a - function. - - fcn: Function - The function to invoke. - - done: Function - Callback to invoke upon completion. - - thisArg: any (optional) - Execution context for the invoked function. - - Examples - -------- - > function predicate( i, clbk ) { clbk( null, i < 5 ); }; - > function fcn( i, next ) { - ... setTimeout( onTimeout, i ); - ... function onTimeout() { - ... next( null, 'boop'+i ); - ... } - ... }; - > function done( error, result ) { - ... if ( error ) { - ... throw error; - ... } - ... console.log( result ); - ... }; - > {{alias}}( predicate, fcn, done ) - boop: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4a543d9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,83 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 whileAsync = require( './index' ); - -const fcn = ( i: number, next: Function ): void => { - if ( i === void 0 ) { - throw new Error( '`i` is missing.' ); - } - next(); -}; - -const predicate = ( i: number, clbk: Function ): void => { - clbk( null, i < 5 ); -}; - -const done = ( error: Error | null ): void => { - if ( error ) { - throw error; - } -}; - - -// TESTS // - -// The function returns void... -{ - whileAsync( predicate, fcn, done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a predicate function... -{ - whileAsync( 2, fcn, done ); // $ExpectError - whileAsync( false, fcn, done ); // $ExpectError - whileAsync( true, fcn, done ); // $ExpectError - whileAsync( 'abc', fcn, done ); // $ExpectError - whileAsync( {}, fcn, done ); // $ExpectError - whileAsync( [], fcn, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function having a supported signature... -{ - whileAsync( predicate, 2, done ); // $ExpectError - whileAsync( predicate, false, done ); // $ExpectError - whileAsync( predicate, true, done ); // $ExpectError - whileAsync( predicate, 'abc', done ); // $ExpectError - whileAsync( predicate, {}, done ); // $ExpectError - whileAsync( predicate, [], done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a done callback argument which is not a function having a supported signature... -{ - whileAsync( predicate, fcn, 2 ); // $ExpectError - whileAsync( predicate, fcn, false ); // $ExpectError - whileAsync( predicate, fcn, true ); // $ExpectError - whileAsync( predicate, fcn, 'abc' ); // $ExpectError - whileAsync( predicate, fcn, {} ); // $ExpectError - whileAsync( predicate, fcn, [] ); // $ExpectError - whileAsync( predicate, fcn, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - whileAsync(); // $ExpectError - whileAsync( predicate ); // $ExpectError - whileAsync( predicate, fcn ); // $ExpectError - whileAsync( predicate, fcn, done, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a6af668..0000000 --- a/examples/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var repeatString = require( '@stdlib/string-repeat' ); -var whileAsync = require( './../lib' ); - -function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } -} - -function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, repeatString( 'beep', i+1 ) ); - } -} - -function done( error, result ) { - if ( error ) { - throw error; - } - console.log( result ); -} - -whileAsync( predicate, fcn, done ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..5136fa0 --- /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-function@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function n(n,e,o,i){var s,l;if(!r(n))throw new TypeError(t("1Rr3c",n));if(!r(e))throw new TypeError(t("1Rr2H",e));if(!r(o))throw new TypeError(t("1Rr3N",o));function f(r,t){return r?o(r):t?e.call(i,l,h):(s.length&&s.unshift(null),void o.apply(null,s))}function h(r){var t;if(r)return o(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;8LA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a13bd4..0000000 --- a/lib/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Invoke a function while a test condition is true. -* -* @module @stdlib/utils-async-while -* -* @example -* var whileAsync = require( '@stdlib/utils-async-while' ); -* -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c1bab44..0000000 --- a/lib/main.js +++ /dev/null @@ -1,128 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Invokes a function while a test condition is true. -* -* @param {Function} predicate - function which indicates whether to continue invoking a function -* @param {Function} fcn - function to invoke -* @param {Callback} done - callback to invoke upon completion -* @param {*} [thisArg] - execution context for the invoked function -* @throws {TypeError} first argument must be a function -* @throws {TypeError} second argument must be a function -* @throws {TypeError} third argument must be a function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -function whileAsync( predicate, fcn, done, thisArg ) { - var args; - var idx; - if ( !isFunction( predicate ) ) { - throw new TypeError( format( '1Rr3c', predicate ) ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '1Rr2H', fcn ) ); - } - if ( !isFunction( done ) ) { - throw new TypeError( format( '1Rr3N', done ) ); - } - args = []; - idx = 0; - predicate( idx, onPredicate ); - - /** - * Callback invoked upon a predicate result. - * - * @private - * @param {(Error|null)} error - error object - * @param {boolean} result - predicate result - * @returns {void} - */ - function onPredicate( error, result ) { - if ( error ) { - return done( error ); - } - if ( result ) { - return fcn.call( thisArg, idx, next ); - } - if ( args.length ) { - args.unshift( null ); // error argument - } - done.apply( null, args ); - } - - /** - * Callback invoked upon completion of a provided function. - * - * @private - * @param {(Error|null)} error - error object - * @param {...*} results - function results - * @returns {void} - */ - function next( error ) { - var i; - if ( error ) { - return done( error ); - } - idx += 1; - - // Cache the most recent results... - if ( arguments.length > 1 ) { - args = new Array( arguments.length-1 ); - for ( i = 1; i < arguments.length; i++ ) { - args[ i-1 ] = arguments[ i ]; - } - } - // Run the test condition: - predicate( idx, onPredicate ); - } -} - - -// EXPORTS // - -module.exports = whileAsync; diff --git a/package.json b/package.json index c14cc66..fec327b 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Invoke a function while a test condition is true.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,35 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/math-base-assert-is-nan": "^0.2.0", - "@stdlib/random-base-randu": "^0.2.0", - "@stdlib/string-repeat": "^0.2.0", - "@stdlib/utils-noop": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.0" - }, - "engines": { - "node": ">=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..a6615ea --- /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 78d0688..0000000 --- a/test/test.js +++ /dev/null @@ -1,328 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 whileAsync = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof whileAsync, 'function', 'main export is a function' ); - t.end(); -}); - -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() { - whileAsync( value, noop, 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() { - whileAsync( noop, value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a callback 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() { - whileAsync( noop, noop, value ); - }; - } -}); - -tape( 'while a test condition is true, the function invokes a provided function', function test( t ) { - var indices1 = [ 0, 1, 2, 3, 4, 5 ]; - var indices2 = [ 0, 1, 2, 3, 4 ]; - var j = -1; - var k = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices1[ j ], 'provides expected value' ); - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - k += 1; - t.strictEqual( i, indices2[ k ], 'provides expected value' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'while a test condition is true, the function invokes a provided function (always false)', function test( t ) { - var indices = [ 0 ]; - var j = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices[ j ], 'provides expected value' ); - clbk( null, false ); - } - - function fcn( i, next ) { - t.fail( 'should never be invoked' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx = { - 'count': 0 - }; - - whileAsync( predicate, fcn, done, ctx ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - this.count += 1; // eslint-disable-line no-invalid-this - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( ctx.count, 5, 'updates context' ); - t.end(); - } -}); - -tape( 'the function provides any results to a `done` callback', function test( t ) { - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, 'beep'+i, 'boop'+i, 'woot'+i ); - } - } - - function done( error, str1, str2, str3 ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( str1, 'beep4', 'returns expected value' ); - t.strictEqual( str2, 'boop4', 'returns expected value' ); - t.strictEqual( str3, 'woot4', 'returns expected value' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the predicate function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - if ( i === 1 ) { - return clbk( new Error( 'beep' ) ); - } - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 2, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the provided function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - if ( i === 2 ) { - return next( new Error( 'boop' ) ); - } - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 3, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'the function does not guarantee asynchronous execution', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - k = 1; - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - next(); - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( k, 0, 'releases the zalgo' ); - t.end(); - } -}); From a8208f2d458585bc90c2e2af36494fd72cfcf76b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 22 Feb 2024 01:44:56 +0000 Subject: [PATCH 095/143] 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 c9700e7..5251296 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import whileAsync from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-async-while@esm/index.mjs'; +import whileAsync from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-async-while@v0.2.1-esm/index.mjs'; ``` #### whileAsync( predicate, fcn, done\[, thisArg ] ) @@ -215,7 +215,7 @@ function done( error ) { - - - - From 12953d1d1d2b5480a0c88ad099ca9ce079914061 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 02:38:27 +0000 Subject: [PATCH 099/143] 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 | 105 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 72 - docs/types/test.ts | 83 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 57 - lib/main.js | 128 - package.json | 57 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 328 -- 43 files changed, 4867 insertions(+), 4172 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 (100%) 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 6e36d00..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-03-01T01:08:53.593Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 0f8dec8..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/async/while) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 9633c26..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/async/while) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 0bdf3fd..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: '8 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' - # 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 + + ```
@@ -292,7 +283,7 @@ whileAsync( predicate, fcn, done ); ## 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]. @@ -357,13 +348,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until +[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until/tree/esm -[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while +[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while/tree/esm -[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until +[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until/tree/esm -[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while +[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while/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 7c83acf..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var whileAsync = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); - -bench( pkg+'::sync_predicate', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2c3ed87..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/async/while" -%% click B href "https://github.com/stdlib-js/utils-async-while/tree/main" -%% click C href "https://github.com/stdlib-js/utils-async-while/tree/production" -%% click D href "https://github.com/stdlib-js/utils-async-while/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-async-while/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-async-while/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/async/while -[production-url]: https://github.com/stdlib-js/utils-async-while/tree/production -[deno-url]: https://github.com/stdlib-js/utils-async-while/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-async-while/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-async-while/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-async-while/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-async-while/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-async-while/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 efdafdf..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import whileAsync from '../docs/types/index'; -export = whileAsync; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 159efee..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var v=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var m=v(function(p,g){ -var s=require('@stdlib/assert-is-function/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist');function c(t,r,e,o){var u,i;if(!s(t))throw new TypeError(l('1Rr3c',t));if(!s(r))throw new TypeError(l('1Rr2H',r));if(!s(e))throw new TypeError(l('1Rr3N',e));u=[],i=0,t(i,f);function f(a,n){if(a)return e(a);if(n)return r.call(o,i,h);u.length&&u.unshift(null),e.apply(null,u)}function h(a){var n;if(a)return e(a);if(i+=1,arguments.length>1)for(u=new Array(arguments.length-1),n=1;n 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = whileAsync;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Invoke a function while a test condition is true.\n*\n* @module @stdlib/utils-async-while\n*\n* @example\n* var whileAsync = require( '@stdlib/utils-async-while' );\n*\n* function predicate( i, clbk ) {\n* clbk( null, i < 5 );\n* }\n*\n* function fcn( i, next ) {\n* setTimeout( onTimeout, i );\n* function onTimeout() {\n* console.log( 'beep: %d', i );\n* next();\n* }\n* }\n*\n* function done( error ) {\n* if ( error ) {\n* throw error;\n* }\n* }\n*\n* whileAsync( predicate, fcn, done );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAS,QAAS,uBAAwB,EAqC9C,SAASC,EAAYC,EAAWC,EAAKC,EAAMC,EAAU,CACpD,IAAIC,EACAC,EACJ,GAAK,CAACR,EAAYG,CAAU,EAC3B,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAU,CAAE,EAE/G,GAAK,CAACH,EAAYI,CAAI,EACrB,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAI,CAAE,EAE1G,GAAK,CAACJ,EAAYK,CAAK,EACtB,MAAM,IAAI,UAAWJ,EAAQ,oEAAqEI,CAAK,CAAE,EAE1GE,EAAO,CAAC,EACRC,EAAM,EACNL,EAAWK,EAAKC,CAAY,EAU5B,SAASA,EAAaC,EAAOC,EAAS,CACrC,GAAKD,EACJ,OAAOL,EAAMK,CAAM,EAEpB,GAAKC,EACJ,OAAOP,EAAI,KAAME,EAASE,EAAKI,CAAK,EAEhCL,EAAK,QACTA,EAAK,QAAS,IAAK,EAEpBF,EAAK,MAAO,KAAME,CAAK,CACxB,CAUA,SAASK,EAAMF,EAAQ,CACtB,IAAIG,EACJ,GAAKH,EACJ,OAAOL,EAAMK,CAAM,EAKpB,GAHAF,GAAO,EAGF,UAAU,OAAS,EAEvB,IADAD,EAAO,IAAI,MAAO,UAAU,OAAO,CAAE,EAC/BM,EAAI,EAAGA,EAAI,UAAU,OAAQA,IAClCN,EAAMM,EAAE,CAAE,EAAI,UAAWA,CAAE,EAI7BV,EAAWK,EAAKC,CAAY,CAC7B,CACD,CAKAV,EAAO,QAAUG,IC5EjB,IAAIY,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "format", "whileAsync", "predicate", "fcn", "done", "thisArg", "args", "idx", "onPredicate", "error", "result", "next", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index d7ca8c9..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,72 +0,0 @@ - -{{alias}}( predicate, fcn, done[, thisArg] ) - Invokes a function while a test condition is true. - - The predicate function is provided two arguments: - - - `i`: iteration number (starting from zero) - - `clbk`: a callback indicating whether to invoke `fcn` - - The `clbk` function accepts two arguments: - - - `error`: error argument - - `bool`: test result - - If the test result is truthy, the function invokes `fcn`; otherwise, the - function invokes the `done` callback. - - The function to invoke is provided two arguments: - - - `i`: iteration number (starting from zero) - - `next`: a callback which must be invoked before proceeding to the next - iteration - - The first argument of the `next` callback is an `error` argument. If `fcn` - calls the `next` callback with a truthy `error` argument, the function - suspends execution and immediately calls the `done` callback for subsequent - `error` handling. - - The `done` callback is invoked with an `error` argument and any arguments - passed to the final `next` callback. - - Execution is *not* guaranteed to be asynchronous. To guarantee asynchrony, - wrap the `done` callback in a function which either executes at the end of - the current stack (e.g., `nextTick`) or during a subsequent turn of the - event loop (e.g., `setImmediate`, `setTimeout`). - - Parameters - ---------- - predicate: Function - The predicate function which indicates whether to continue invoking a - function. - - fcn: Function - The function to invoke. - - done: Function - Callback to invoke upon completion. - - thisArg: any (optional) - Execution context for the invoked function. - - Examples - -------- - > function predicate( i, clbk ) { clbk( null, i < 5 ); }; - > function fcn( i, next ) { - ... setTimeout( onTimeout, i ); - ... function onTimeout() { - ... next( null, 'boop'+i ); - ... } - ... }; - > function done( error, result ) { - ... if ( error ) { - ... throw error; - ... } - ... console.log( result ); - ... }; - > {{alias}}( predicate, fcn, done ) - boop: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4a543d9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,83 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 whileAsync = require( './index' ); - -const fcn = ( i: number, next: Function ): void => { - if ( i === void 0 ) { - throw new Error( '`i` is missing.' ); - } - next(); -}; - -const predicate = ( i: number, clbk: Function ): void => { - clbk( null, i < 5 ); -}; - -const done = ( error: Error | null ): void => { - if ( error ) { - throw error; - } -}; - - -// TESTS // - -// The function returns void... -{ - whileAsync( predicate, fcn, done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a predicate function... -{ - whileAsync( 2, fcn, done ); // $ExpectError - whileAsync( false, fcn, done ); // $ExpectError - whileAsync( true, fcn, done ); // $ExpectError - whileAsync( 'abc', fcn, done ); // $ExpectError - whileAsync( {}, fcn, done ); // $ExpectError - whileAsync( [], fcn, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function having a supported signature... -{ - whileAsync( predicate, 2, done ); // $ExpectError - whileAsync( predicate, false, done ); // $ExpectError - whileAsync( predicate, true, done ); // $ExpectError - whileAsync( predicate, 'abc', done ); // $ExpectError - whileAsync( predicate, {}, done ); // $ExpectError - whileAsync( predicate, [], done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a done callback argument which is not a function having a supported signature... -{ - whileAsync( predicate, fcn, 2 ); // $ExpectError - whileAsync( predicate, fcn, false ); // $ExpectError - whileAsync( predicate, fcn, true ); // $ExpectError - whileAsync( predicate, fcn, 'abc' ); // $ExpectError - whileAsync( predicate, fcn, {} ); // $ExpectError - whileAsync( predicate, fcn, [] ); // $ExpectError - whileAsync( predicate, fcn, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - whileAsync(); // $ExpectError - whileAsync( predicate ); // $ExpectError - whileAsync( predicate, fcn ); // $ExpectError - whileAsync( predicate, fcn, done, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a6af668..0000000 --- a/examples/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var repeatString = require( '@stdlib/string-repeat' ); -var whileAsync = require( './../lib' ); - -function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } -} - -function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, repeatString( 'beep', i+1 ) ); - } -} - -function done( error, result ) { - if ( error ) { - throw error; - } - console.log( result ); -} - -whileAsync( predicate, fcn, done ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..5136fa0 --- /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-function@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function n(n,e,o,i){var s,l;if(!r(n))throw new TypeError(t("1Rr3c",n));if(!r(e))throw new TypeError(t("1Rr2H",e));if(!r(o))throw new TypeError(t("1Rr3N",o));function f(r,t){return r?o(r):t?e.call(i,l,h):(s.length&&s.unshift(null),void o.apply(null,s))}function h(r){var t;if(r)return o(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;8LA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a13bd4..0000000 --- a/lib/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Invoke a function while a test condition is true. -* -* @module @stdlib/utils-async-while -* -* @example -* var whileAsync = require( '@stdlib/utils-async-while' ); -* -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c1bab44..0000000 --- a/lib/main.js +++ /dev/null @@ -1,128 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Invokes a function while a test condition is true. -* -* @param {Function} predicate - function which indicates whether to continue invoking a function -* @param {Function} fcn - function to invoke -* @param {Callback} done - callback to invoke upon completion -* @param {*} [thisArg] - execution context for the invoked function -* @throws {TypeError} first argument must be a function -* @throws {TypeError} second argument must be a function -* @throws {TypeError} third argument must be a function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -function whileAsync( predicate, fcn, done, thisArg ) { - var args; - var idx; - if ( !isFunction( predicate ) ) { - throw new TypeError( format( '1Rr3c', predicate ) ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '1Rr2H', fcn ) ); - } - if ( !isFunction( done ) ) { - throw new TypeError( format( '1Rr3N', done ) ); - } - args = []; - idx = 0; - predicate( idx, onPredicate ); - - /** - * Callback invoked upon a predicate result. - * - * @private - * @param {(Error|null)} error - error object - * @param {boolean} result - predicate result - * @returns {void} - */ - function onPredicate( error, result ) { - if ( error ) { - return done( error ); - } - if ( result ) { - return fcn.call( thisArg, idx, next ); - } - if ( args.length ) { - args.unshift( null ); // error argument - } - done.apply( null, args ); - } - - /** - * Callback invoked upon completion of a provided function. - * - * @private - * @param {(Error|null)} error - error object - * @param {...*} results - function results - * @returns {void} - */ - function next( error ) { - var i; - if ( error ) { - return done( error ); - } - idx += 1; - - // Cache the most recent results... - if ( arguments.length > 1 ) { - args = new Array( arguments.length-1 ); - for ( i = 1; i < arguments.length; i++ ) { - args[ i-1 ] = arguments[ i ]; - } - } - // Run the test condition: - predicate( idx, onPredicate ); - } -} - - -// EXPORTS // - -module.exports = whileAsync; diff --git a/package.json b/package.json index 2ab9171..fec327b 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Invoke a function while a test condition is true.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/math-base-assert-is-nan": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.1", - "@stdlib/string-repeat": "^0.2.1", - "@stdlib/utils-noop": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..a6615ea --- /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 78d0688..0000000 --- a/test/test.js +++ /dev/null @@ -1,328 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 whileAsync = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof whileAsync, 'function', 'main export is a function' ); - t.end(); -}); - -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() { - whileAsync( value, noop, 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() { - whileAsync( noop, value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a callback 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() { - whileAsync( noop, noop, value ); - }; - } -}); - -tape( 'while a test condition is true, the function invokes a provided function', function test( t ) { - var indices1 = [ 0, 1, 2, 3, 4, 5 ]; - var indices2 = [ 0, 1, 2, 3, 4 ]; - var j = -1; - var k = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices1[ j ], 'provides expected value' ); - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - k += 1; - t.strictEqual( i, indices2[ k ], 'provides expected value' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'while a test condition is true, the function invokes a provided function (always false)', function test( t ) { - var indices = [ 0 ]; - var j = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices[ j ], 'provides expected value' ); - clbk( null, false ); - } - - function fcn( i, next ) { - t.fail( 'should never be invoked' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx = { - 'count': 0 - }; - - whileAsync( predicate, fcn, done, ctx ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - this.count += 1; // eslint-disable-line no-invalid-this - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( ctx.count, 5, 'updates context' ); - t.end(); - } -}); - -tape( 'the function provides any results to a `done` callback', function test( t ) { - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, 'beep'+i, 'boop'+i, 'woot'+i ); - } - } - - function done( error, str1, str2, str3 ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( str1, 'beep4', 'returns expected value' ); - t.strictEqual( str2, 'boop4', 'returns expected value' ); - t.strictEqual( str3, 'woot4', 'returns expected value' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the predicate function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - if ( i === 1 ) { - return clbk( new Error( 'beep' ) ); - } - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 2, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the provided function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - if ( i === 2 ) { - return next( new Error( 'boop' ) ); - } - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 3, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'the function does not guarantee asynchronous execution', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - k = 1; - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - next(); - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( k, 0, 'releases the zalgo' ); - t.end(); - } -}); From 742beb6ced0a5a100dea58bf254b896412113968 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 01:20:06 +0000 Subject: [PATCH 100/143] 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 1dafc2a..c1bab44 100644 --- a/lib/main.js +++ b/lib/main.js @@ -21,7 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -62,13 +62,13 @@ function whileAsync( predicate, fcn, done, thisArg ) { var args; var idx; if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '1Rr3c', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '1Rr2H', fcn ) ); } if ( !isFunction( done ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', done ) ); + throw new TypeError( format( '1Rr3N', done ) ); } args = []; idx = 0; diff --git a/package.json b/package.json index c943fbd..2ab9171 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ }, "dependencies": { "@stdlib/assert-is-function": "^0.2.1", - "@stdlib/string-format": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1", "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { From f17237b1f006bcb1d8d6663d882384590dec47ce Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 02:53:35 +0000 Subject: [PATCH 101/143] Remove files --- index.d.ts | 127 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4974 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 163e8ba..0000000 --- a/index.d.ts +++ /dev/null @@ -1,127 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Callback function. -*/ -type Nullary = () => void; - -/** -* Callback function. -* -* @param error - encountered error or null -*/ -type Unary = ( error: Error | null ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Binary = ( error: Error | null, bool: boolean ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Callback = Nullary | Unary | Binary; - -/** -* Callback invoked upon completion. -*/ -type DoneNullary = () => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -*/ -type DoneUnary = ( error: Error | null ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneBinary = ( error: Error | null, ...args: Array ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneCallback = DoneNullary | DoneUnary | DoneBinary; - -/** -* Checks whether an element in a collection passes a test. -* -* @param i - iteration number (starting from one) -* @param clbk - a callback indicating whether to invoke `fcn` -*/ -type Predicate = ( i: number, clbk: Callback ) => void; - -/** -* Invoked function. -* -* @param i - iteration number (starting from zero) -* @param next - a callback which must be invoked before proceeding to the next iteration -*/ -type Fcn = ( i: number, next: Function ) => void; - -/** -* Invokes a function while a test condition is true. -* -* @param predicate - function which indicates whether to continue invoking a function -* @param fcn - function to invoke -* @param done - callback to invoke upon completion -* @param thisArg - execution context for the invoked function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -declare function whileAsync( predicate: Predicate, fcn: Fcn, done: DoneCallback, thisArg?: any ): void; - - -// EXPORTS // - -export = whileAsync; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 5136fa0..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-function@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function n(n,e,o,i){var s,l;if(!r(n))throw new TypeError(t("1Rr3c",n));if(!r(e))throw new TypeError(t("1Rr2H",e));if(!r(o))throw new TypeError(t("1Rr3N",o));function f(r,t){return r?o(r):t?e.call(i,l,h):(s.length&&s.unshift(null),void o.apply(null,s))}function h(r){var t;if(r)return o(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;8LA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index a6615ea..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 467eba22736834ce5b8b09b07d2e07a0d1e0e65e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 02:53:49 +0000 Subject: [PATCH 102/143] 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 | 105 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 72 - docs/types/test.ts | 83 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 57 - lib/main.js | 128 - package.json | 57 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 328 -- 43 files changed, 4867 insertions(+), 4175 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 (100%) 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 d5694f0..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-04-01T01:00:49.755Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 0f8dec8..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/async/while) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 9633c26..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/async/while) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 0bdf3fd..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: '8 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' - # 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 + + ```
@@ -292,7 +283,7 @@ whileAsync( predicate, fcn, done ); ## 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]. @@ -357,13 +348,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until +[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until/tree/esm -[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while +[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while/tree/esm -[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until +[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until/tree/esm -[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while +[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while/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 7c83acf..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var whileAsync = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); - -bench( pkg+'::sync_predicate', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2c3ed87..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/async/while" -%% click B href "https://github.com/stdlib-js/utils-async-while/tree/main" -%% click C href "https://github.com/stdlib-js/utils-async-while/tree/production" -%% click D href "https://github.com/stdlib-js/utils-async-while/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-async-while/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-async-while/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/async/while -[production-url]: https://github.com/stdlib-js/utils-async-while/tree/production -[deno-url]: https://github.com/stdlib-js/utils-async-while/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-async-while/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-async-while/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-async-while/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-async-while/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-async-while/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 efdafdf..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import whileAsync from '../docs/types/index'; -export = whileAsync; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 159efee..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var v=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var m=v(function(p,g){ -var s=require('@stdlib/assert-is-function/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist');function c(t,r,e,o){var u,i;if(!s(t))throw new TypeError(l('1Rr3c',t));if(!s(r))throw new TypeError(l('1Rr2H',r));if(!s(e))throw new TypeError(l('1Rr3N',e));u=[],i=0,t(i,f);function f(a,n){if(a)return e(a);if(n)return r.call(o,i,h);u.length&&u.unshift(null),e.apply(null,u)}function h(a){var n;if(a)return e(a);if(i+=1,arguments.length>1)for(u=new Array(arguments.length-1),n=1;n 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = whileAsync;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Invoke a function while a test condition is true.\n*\n* @module @stdlib/utils-async-while\n*\n* @example\n* var whileAsync = require( '@stdlib/utils-async-while' );\n*\n* function predicate( i, clbk ) {\n* clbk( null, i < 5 );\n* }\n*\n* function fcn( i, next ) {\n* setTimeout( onTimeout, i );\n* function onTimeout() {\n* console.log( 'beep: %d', i );\n* next();\n* }\n* }\n*\n* function done( error ) {\n* if ( error ) {\n* throw error;\n* }\n* }\n*\n* whileAsync( predicate, fcn, done );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAS,QAAS,uBAAwB,EAqC9C,SAASC,EAAYC,EAAWC,EAAKC,EAAMC,EAAU,CACpD,IAAIC,EACAC,EACJ,GAAK,CAACR,EAAYG,CAAU,EAC3B,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAU,CAAE,EAE/G,GAAK,CAACH,EAAYI,CAAI,EACrB,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAI,CAAE,EAE1G,GAAK,CAACJ,EAAYK,CAAK,EACtB,MAAM,IAAI,UAAWJ,EAAQ,oEAAqEI,CAAK,CAAE,EAE1GE,EAAO,CAAC,EACRC,EAAM,EACNL,EAAWK,EAAKC,CAAY,EAU5B,SAASA,EAAaC,EAAOC,EAAS,CACrC,GAAKD,EACJ,OAAOL,EAAMK,CAAM,EAEpB,GAAKC,EACJ,OAAOP,EAAI,KAAME,EAASE,EAAKI,CAAK,EAEhCL,EAAK,QACTA,EAAK,QAAS,IAAK,EAEpBF,EAAK,MAAO,KAAME,CAAK,CACxB,CAUA,SAASK,EAAMF,EAAQ,CACtB,IAAIG,EACJ,GAAKH,EACJ,OAAOL,EAAMK,CAAM,EAKpB,GAHAF,GAAO,EAGF,UAAU,OAAS,EAEvB,IADAD,EAAO,IAAI,MAAO,UAAU,OAAO,CAAE,EAC/BM,EAAI,EAAGA,EAAI,UAAU,OAAQA,IAClCN,EAAMM,EAAE,CAAE,EAAI,UAAWA,CAAE,EAI7BV,EAAWK,EAAKC,CAAY,CAC7B,CACD,CAKAV,EAAO,QAAUG,IC5EjB,IAAIY,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "format", "whileAsync", "predicate", "fcn", "done", "thisArg", "args", "idx", "onPredicate", "error", "result", "next", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index d7ca8c9..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,72 +0,0 @@ - -{{alias}}( predicate, fcn, done[, thisArg] ) - Invokes a function while a test condition is true. - - The predicate function is provided two arguments: - - - `i`: iteration number (starting from zero) - - `clbk`: a callback indicating whether to invoke `fcn` - - The `clbk` function accepts two arguments: - - - `error`: error argument - - `bool`: test result - - If the test result is truthy, the function invokes `fcn`; otherwise, the - function invokes the `done` callback. - - The function to invoke is provided two arguments: - - - `i`: iteration number (starting from zero) - - `next`: a callback which must be invoked before proceeding to the next - iteration - - The first argument of the `next` callback is an `error` argument. If `fcn` - calls the `next` callback with a truthy `error` argument, the function - suspends execution and immediately calls the `done` callback for subsequent - `error` handling. - - The `done` callback is invoked with an `error` argument and any arguments - passed to the final `next` callback. - - Execution is *not* guaranteed to be asynchronous. To guarantee asynchrony, - wrap the `done` callback in a function which either executes at the end of - the current stack (e.g., `nextTick`) or during a subsequent turn of the - event loop (e.g., `setImmediate`, `setTimeout`). - - Parameters - ---------- - predicate: Function - The predicate function which indicates whether to continue invoking a - function. - - fcn: Function - The function to invoke. - - done: Function - Callback to invoke upon completion. - - thisArg: any (optional) - Execution context for the invoked function. - - Examples - -------- - > function predicate( i, clbk ) { clbk( null, i < 5 ); }; - > function fcn( i, next ) { - ... setTimeout( onTimeout, i ); - ... function onTimeout() { - ... next( null, 'boop'+i ); - ... } - ... }; - > function done( error, result ) { - ... if ( error ) { - ... throw error; - ... } - ... console.log( result ); - ... }; - > {{alias}}( predicate, fcn, done ) - boop: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4a543d9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,83 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 whileAsync = require( './index' ); - -const fcn = ( i: number, next: Function ): void => { - if ( i === void 0 ) { - throw new Error( '`i` is missing.' ); - } - next(); -}; - -const predicate = ( i: number, clbk: Function ): void => { - clbk( null, i < 5 ); -}; - -const done = ( error: Error | null ): void => { - if ( error ) { - throw error; - } -}; - - -// TESTS // - -// The function returns void... -{ - whileAsync( predicate, fcn, done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a predicate function... -{ - whileAsync( 2, fcn, done ); // $ExpectError - whileAsync( false, fcn, done ); // $ExpectError - whileAsync( true, fcn, done ); // $ExpectError - whileAsync( 'abc', fcn, done ); // $ExpectError - whileAsync( {}, fcn, done ); // $ExpectError - whileAsync( [], fcn, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function having a supported signature... -{ - whileAsync( predicate, 2, done ); // $ExpectError - whileAsync( predicate, false, done ); // $ExpectError - whileAsync( predicate, true, done ); // $ExpectError - whileAsync( predicate, 'abc', done ); // $ExpectError - whileAsync( predicate, {}, done ); // $ExpectError - whileAsync( predicate, [], done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a done callback argument which is not a function having a supported signature... -{ - whileAsync( predicate, fcn, 2 ); // $ExpectError - whileAsync( predicate, fcn, false ); // $ExpectError - whileAsync( predicate, fcn, true ); // $ExpectError - whileAsync( predicate, fcn, 'abc' ); // $ExpectError - whileAsync( predicate, fcn, {} ); // $ExpectError - whileAsync( predicate, fcn, [] ); // $ExpectError - whileAsync( predicate, fcn, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - whileAsync(); // $ExpectError - whileAsync( predicate ); // $ExpectError - whileAsync( predicate, fcn ); // $ExpectError - whileAsync( predicate, fcn, done, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a6af668..0000000 --- a/examples/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var repeatString = require( '@stdlib/string-repeat' ); -var whileAsync = require( './../lib' ); - -function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } -} - -function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, repeatString( 'beep', i+1 ) ); - } -} - -function done( error, result ) { - if ( error ) { - throw error; - } - console.log( result ); -} - -whileAsync( predicate, fcn, done ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..5136fa0 --- /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-function@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function n(n,e,o,i){var s,l;if(!r(n))throw new TypeError(t("1Rr3c",n));if(!r(e))throw new TypeError(t("1Rr2H",e));if(!r(o))throw new TypeError(t("1Rr3N",o));function f(r,t){return r?o(r):t?e.call(i,l,h):(s.length&&s.unshift(null),void o.apply(null,s))}function h(r){var t;if(r)return o(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;8LA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a13bd4..0000000 --- a/lib/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Invoke a function while a test condition is true. -* -* @module @stdlib/utils-async-while -* -* @example -* var whileAsync = require( '@stdlib/utils-async-while' ); -* -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c1bab44..0000000 --- a/lib/main.js +++ /dev/null @@ -1,128 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Invokes a function while a test condition is true. -* -* @param {Function} predicate - function which indicates whether to continue invoking a function -* @param {Function} fcn - function to invoke -* @param {Callback} done - callback to invoke upon completion -* @param {*} [thisArg] - execution context for the invoked function -* @throws {TypeError} first argument must be a function -* @throws {TypeError} second argument must be a function -* @throws {TypeError} third argument must be a function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -function whileAsync( predicate, fcn, done, thisArg ) { - var args; - var idx; - if ( !isFunction( predicate ) ) { - throw new TypeError( format( '1Rr3c', predicate ) ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '1Rr2H', fcn ) ); - } - if ( !isFunction( done ) ) { - throw new TypeError( format( '1Rr3N', done ) ); - } - args = []; - idx = 0; - predicate( idx, onPredicate ); - - /** - * Callback invoked upon a predicate result. - * - * @private - * @param {(Error|null)} error - error object - * @param {boolean} result - predicate result - * @returns {void} - */ - function onPredicate( error, result ) { - if ( error ) { - return done( error ); - } - if ( result ) { - return fcn.call( thisArg, idx, next ); - } - if ( args.length ) { - args.unshift( null ); // error argument - } - done.apply( null, args ); - } - - /** - * Callback invoked upon completion of a provided function. - * - * @private - * @param {(Error|null)} error - error object - * @param {...*} results - function results - * @returns {void} - */ - function next( error ) { - var i; - if ( error ) { - return done( error ); - } - idx += 1; - - // Cache the most recent results... - if ( arguments.length > 1 ) { - args = new Array( arguments.length-1 ); - for ( i = 1; i < arguments.length; i++ ) { - args[ i-1 ] = arguments[ i ]; - } - } - // Run the test condition: - predicate( idx, onPredicate ); - } -} - - -// EXPORTS // - -module.exports = whileAsync; diff --git a/package.json b/package.json index 2ab9171..fec327b 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Invoke a function while a test condition is true.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/math-base-assert-is-nan": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.1", - "@stdlib/string-repeat": "^0.2.1", - "@stdlib/utils-noop": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..a6615ea --- /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 78d0688..0000000 --- a/test/test.js +++ /dev/null @@ -1,328 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 whileAsync = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof whileAsync, 'function', 'main export is a function' ); - t.end(); -}); - -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() { - whileAsync( value, noop, 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() { - whileAsync( noop, value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a callback 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() { - whileAsync( noop, noop, value ); - }; - } -}); - -tape( 'while a test condition is true, the function invokes a provided function', function test( t ) { - var indices1 = [ 0, 1, 2, 3, 4, 5 ]; - var indices2 = [ 0, 1, 2, 3, 4 ]; - var j = -1; - var k = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices1[ j ], 'provides expected value' ); - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - k += 1; - t.strictEqual( i, indices2[ k ], 'provides expected value' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'while a test condition is true, the function invokes a provided function (always false)', function test( t ) { - var indices = [ 0 ]; - var j = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices[ j ], 'provides expected value' ); - clbk( null, false ); - } - - function fcn( i, next ) { - t.fail( 'should never be invoked' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx = { - 'count': 0 - }; - - whileAsync( predicate, fcn, done, ctx ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - this.count += 1; // eslint-disable-line no-invalid-this - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( ctx.count, 5, 'updates context' ); - t.end(); - } -}); - -tape( 'the function provides any results to a `done` callback', function test( t ) { - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, 'beep'+i, 'boop'+i, 'woot'+i ); - } - } - - function done( error, str1, str2, str3 ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( str1, 'beep4', 'returns expected value' ); - t.strictEqual( str2, 'boop4', 'returns expected value' ); - t.strictEqual( str3, 'woot4', 'returns expected value' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the predicate function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - if ( i === 1 ) { - return clbk( new Error( 'beep' ) ); - } - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 2, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the provided function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - if ( i === 2 ) { - return next( new Error( 'boop' ) ); - } - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 3, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'the function does not guarantee asynchronous execution', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - k = 1; - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - next(); - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( k, 0, 'releases the zalgo' ); - t.end(); - } -}); From c40282c9dfb9b13fb886814f865d1434439ba33b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 11 Apr 2024 21:27:11 +0000 Subject: [PATCH 103/143] 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 1dafc2a..c1bab44 100644 --- a/lib/main.js +++ b/lib/main.js @@ -21,7 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -62,13 +62,13 @@ function whileAsync( predicate, fcn, done, thisArg ) { var args; var idx; if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '1Rr3c', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '1Rr2H', fcn ) ); } if ( !isFunction( done ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', done ) ); + throw new TypeError( format( '1Rr3N', done ) ); } args = []; idx = 0; diff --git a/package.json b/package.json index c943fbd..2ab9171 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ }, "dependencies": { "@stdlib/assert-is-function": "^0.2.1", - "@stdlib/string-format": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1", "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { From bdab747c494137859b87745bd440ab265f5a9248 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 11 Apr 2024 22:41:46 +0000 Subject: [PATCH 104/143] Remove files --- index.d.ts | 127 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4974 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 163e8ba..0000000 --- a/index.d.ts +++ /dev/null @@ -1,127 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Callback function. -*/ -type Nullary = () => void; - -/** -* Callback function. -* -* @param error - encountered error or null -*/ -type Unary = ( error: Error | null ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Binary = ( error: Error | null, bool: boolean ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Callback = Nullary | Unary | Binary; - -/** -* Callback invoked upon completion. -*/ -type DoneNullary = () => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -*/ -type DoneUnary = ( error: Error | null ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneBinary = ( error: Error | null, ...args: Array ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneCallback = DoneNullary | DoneUnary | DoneBinary; - -/** -* Checks whether an element in a collection passes a test. -* -* @param i - iteration number (starting from one) -* @param clbk - a callback indicating whether to invoke `fcn` -*/ -type Predicate = ( i: number, clbk: Callback ) => void; - -/** -* Invoked function. -* -* @param i - iteration number (starting from zero) -* @param next - a callback which must be invoked before proceeding to the next iteration -*/ -type Fcn = ( i: number, next: Function ) => void; - -/** -* Invokes a function while a test condition is true. -* -* @param predicate - function which indicates whether to continue invoking a function -* @param fcn - function to invoke -* @param done - callback to invoke upon completion -* @param thisArg - execution context for the invoked function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -declare function whileAsync( predicate: Predicate, fcn: Fcn, done: DoneCallback, thisArg?: any ): void; - - -// EXPORTS // - -export = whileAsync; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 5136fa0..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-function@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function n(n,e,o,i){var s,l;if(!r(n))throw new TypeError(t("1Rr3c",n));if(!r(e))throw new TypeError(t("1Rr2H",e));if(!r(o))throw new TypeError(t("1Rr3N",o));function f(r,t){return r?o(r):t?e.call(i,l,h):(s.length&&s.unshift(null),void o.apply(null,s))}function h(r){var t;if(r)return o(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;8LA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index a6615ea..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 18be152281d31c5a202f9f8b6df9db1e9e9ddafb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 11 Apr 2024 22:42:00 +0000 Subject: [PATCH 105/143] 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 | 105 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 72 - docs/types/test.ts | 83 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 57 - lib/main.js | 128 - package.json | 57 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 328 -- 42 files changed, 4867 insertions(+), 4176 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 (100%) 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 0f8dec8..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/async/while) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 9633c26..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/async/while) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 0bdf3fd..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: '8 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' - # 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 + + ```
@@ -292,7 +283,7 @@ whileAsync( predicate, fcn, done ); ## 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]. @@ -357,13 +348,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until +[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until/tree/esm -[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while +[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while/tree/esm -[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until +[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until/tree/esm -[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while +[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while/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 7c83acf..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var whileAsync = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); - -bench( pkg+'::sync_predicate', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2c3ed87..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/async/while" -%% click B href "https://github.com/stdlib-js/utils-async-while/tree/main" -%% click C href "https://github.com/stdlib-js/utils-async-while/tree/production" -%% click D href "https://github.com/stdlib-js/utils-async-while/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-async-while/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-async-while/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/async/while -[production-url]: https://github.com/stdlib-js/utils-async-while/tree/production -[deno-url]: https://github.com/stdlib-js/utils-async-while/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-async-while/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-async-while/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-async-while/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-async-while/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-async-while/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 efdafdf..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import whileAsync from '../docs/types/index'; -export = whileAsync; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 159efee..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var v=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var m=v(function(p,g){ -var s=require('@stdlib/assert-is-function/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist');function c(t,r,e,o){var u,i;if(!s(t))throw new TypeError(l('1Rr3c',t));if(!s(r))throw new TypeError(l('1Rr2H',r));if(!s(e))throw new TypeError(l('1Rr3N',e));u=[],i=0,t(i,f);function f(a,n){if(a)return e(a);if(n)return r.call(o,i,h);u.length&&u.unshift(null),e.apply(null,u)}function h(a){var n;if(a)return e(a);if(i+=1,arguments.length>1)for(u=new Array(arguments.length-1),n=1;n 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = whileAsync;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Invoke a function while a test condition is true.\n*\n* @module @stdlib/utils-async-while\n*\n* @example\n* var whileAsync = require( '@stdlib/utils-async-while' );\n*\n* function predicate( i, clbk ) {\n* clbk( null, i < 5 );\n* }\n*\n* function fcn( i, next ) {\n* setTimeout( onTimeout, i );\n* function onTimeout() {\n* console.log( 'beep: %d', i );\n* next();\n* }\n* }\n*\n* function done( error ) {\n* if ( error ) {\n* throw error;\n* }\n* }\n*\n* whileAsync( predicate, fcn, done );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAS,QAAS,uBAAwB,EAqC9C,SAASC,EAAYC,EAAWC,EAAKC,EAAMC,EAAU,CACpD,IAAIC,EACAC,EACJ,GAAK,CAACR,EAAYG,CAAU,EAC3B,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAU,CAAE,EAE/G,GAAK,CAACH,EAAYI,CAAI,EACrB,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAI,CAAE,EAE1G,GAAK,CAACJ,EAAYK,CAAK,EACtB,MAAM,IAAI,UAAWJ,EAAQ,oEAAqEI,CAAK,CAAE,EAE1GE,EAAO,CAAC,EACRC,EAAM,EACNL,EAAWK,EAAKC,CAAY,EAU5B,SAASA,EAAaC,EAAOC,EAAS,CACrC,GAAKD,EACJ,OAAOL,EAAMK,CAAM,EAEpB,GAAKC,EACJ,OAAOP,EAAI,KAAME,EAASE,EAAKI,CAAK,EAEhCL,EAAK,QACTA,EAAK,QAAS,IAAK,EAEpBF,EAAK,MAAO,KAAME,CAAK,CACxB,CAUA,SAASK,EAAMF,EAAQ,CACtB,IAAIG,EACJ,GAAKH,EACJ,OAAOL,EAAMK,CAAM,EAKpB,GAHAF,GAAO,EAGF,UAAU,OAAS,EAEvB,IADAD,EAAO,IAAI,MAAO,UAAU,OAAO,CAAE,EAC/BM,EAAI,EAAGA,EAAI,UAAU,OAAQA,IAClCN,EAAMM,EAAE,CAAE,EAAI,UAAWA,CAAE,EAI7BV,EAAWK,EAAKC,CAAY,CAC7B,CACD,CAKAV,EAAO,QAAUG,IC5EjB,IAAIY,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "format", "whileAsync", "predicate", "fcn", "done", "thisArg", "args", "idx", "onPredicate", "error", "result", "next", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index d7ca8c9..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,72 +0,0 @@ - -{{alias}}( predicate, fcn, done[, thisArg] ) - Invokes a function while a test condition is true. - - The predicate function is provided two arguments: - - - `i`: iteration number (starting from zero) - - `clbk`: a callback indicating whether to invoke `fcn` - - The `clbk` function accepts two arguments: - - - `error`: error argument - - `bool`: test result - - If the test result is truthy, the function invokes `fcn`; otherwise, the - function invokes the `done` callback. - - The function to invoke is provided two arguments: - - - `i`: iteration number (starting from zero) - - `next`: a callback which must be invoked before proceeding to the next - iteration - - The first argument of the `next` callback is an `error` argument. If `fcn` - calls the `next` callback with a truthy `error` argument, the function - suspends execution and immediately calls the `done` callback for subsequent - `error` handling. - - The `done` callback is invoked with an `error` argument and any arguments - passed to the final `next` callback. - - Execution is *not* guaranteed to be asynchronous. To guarantee asynchrony, - wrap the `done` callback in a function which either executes at the end of - the current stack (e.g., `nextTick`) or during a subsequent turn of the - event loop (e.g., `setImmediate`, `setTimeout`). - - Parameters - ---------- - predicate: Function - The predicate function which indicates whether to continue invoking a - function. - - fcn: Function - The function to invoke. - - done: Function - Callback to invoke upon completion. - - thisArg: any (optional) - Execution context for the invoked function. - - Examples - -------- - > function predicate( i, clbk ) { clbk( null, i < 5 ); }; - > function fcn( i, next ) { - ... setTimeout( onTimeout, i ); - ... function onTimeout() { - ... next( null, 'boop'+i ); - ... } - ... }; - > function done( error, result ) { - ... if ( error ) { - ... throw error; - ... } - ... console.log( result ); - ... }; - > {{alias}}( predicate, fcn, done ) - boop: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4a543d9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,83 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 whileAsync = require( './index' ); - -const fcn = ( i: number, next: Function ): void => { - if ( i === void 0 ) { - throw new Error( '`i` is missing.' ); - } - next(); -}; - -const predicate = ( i: number, clbk: Function ): void => { - clbk( null, i < 5 ); -}; - -const done = ( error: Error | null ): void => { - if ( error ) { - throw error; - } -}; - - -// TESTS // - -// The function returns void... -{ - whileAsync( predicate, fcn, done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a predicate function... -{ - whileAsync( 2, fcn, done ); // $ExpectError - whileAsync( false, fcn, done ); // $ExpectError - whileAsync( true, fcn, done ); // $ExpectError - whileAsync( 'abc', fcn, done ); // $ExpectError - whileAsync( {}, fcn, done ); // $ExpectError - whileAsync( [], fcn, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function having a supported signature... -{ - whileAsync( predicate, 2, done ); // $ExpectError - whileAsync( predicate, false, done ); // $ExpectError - whileAsync( predicate, true, done ); // $ExpectError - whileAsync( predicate, 'abc', done ); // $ExpectError - whileAsync( predicate, {}, done ); // $ExpectError - whileAsync( predicate, [], done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a done callback argument which is not a function having a supported signature... -{ - whileAsync( predicate, fcn, 2 ); // $ExpectError - whileAsync( predicate, fcn, false ); // $ExpectError - whileAsync( predicate, fcn, true ); // $ExpectError - whileAsync( predicate, fcn, 'abc' ); // $ExpectError - whileAsync( predicate, fcn, {} ); // $ExpectError - whileAsync( predicate, fcn, [] ); // $ExpectError - whileAsync( predicate, fcn, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - whileAsync(); // $ExpectError - whileAsync( predicate ); // $ExpectError - whileAsync( predicate, fcn ); // $ExpectError - whileAsync( predicate, fcn, done, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a6af668..0000000 --- a/examples/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var repeatString = require( '@stdlib/string-repeat' ); -var whileAsync = require( './../lib' ); - -function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } -} - -function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, repeatString( 'beep', i+1 ) ); - } -} - -function done( error, result ) { - if ( error ) { - throw error; - } - console.log( result ); -} - -whileAsync( predicate, fcn, done ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..5136fa0 --- /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-function@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function n(n,e,o,i){var s,l;if(!r(n))throw new TypeError(t("1Rr3c",n));if(!r(e))throw new TypeError(t("1Rr2H",e));if(!r(o))throw new TypeError(t("1Rr3N",o));function f(r,t){return r?o(r):t?e.call(i,l,h):(s.length&&s.unshift(null),void o.apply(null,s))}function h(r){var t;if(r)return o(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;8LA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a13bd4..0000000 --- a/lib/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Invoke a function while a test condition is true. -* -* @module @stdlib/utils-async-while -* -* @example -* var whileAsync = require( '@stdlib/utils-async-while' ); -* -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c1bab44..0000000 --- a/lib/main.js +++ /dev/null @@ -1,128 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Invokes a function while a test condition is true. -* -* @param {Function} predicate - function which indicates whether to continue invoking a function -* @param {Function} fcn - function to invoke -* @param {Callback} done - callback to invoke upon completion -* @param {*} [thisArg] - execution context for the invoked function -* @throws {TypeError} first argument must be a function -* @throws {TypeError} second argument must be a function -* @throws {TypeError} third argument must be a function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -function whileAsync( predicate, fcn, done, thisArg ) { - var args; - var idx; - if ( !isFunction( predicate ) ) { - throw new TypeError( format( '1Rr3c', predicate ) ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '1Rr2H', fcn ) ); - } - if ( !isFunction( done ) ) { - throw new TypeError( format( '1Rr3N', done ) ); - } - args = []; - idx = 0; - predicate( idx, onPredicate ); - - /** - * Callback invoked upon a predicate result. - * - * @private - * @param {(Error|null)} error - error object - * @param {boolean} result - predicate result - * @returns {void} - */ - function onPredicate( error, result ) { - if ( error ) { - return done( error ); - } - if ( result ) { - return fcn.call( thisArg, idx, next ); - } - if ( args.length ) { - args.unshift( null ); // error argument - } - done.apply( null, args ); - } - - /** - * Callback invoked upon completion of a provided function. - * - * @private - * @param {(Error|null)} error - error object - * @param {...*} results - function results - * @returns {void} - */ - function next( error ) { - var i; - if ( error ) { - return done( error ); - } - idx += 1; - - // Cache the most recent results... - if ( arguments.length > 1 ) { - args = new Array( arguments.length-1 ); - for ( i = 1; i < arguments.length; i++ ) { - args[ i-1 ] = arguments[ i ]; - } - } - // Run the test condition: - predicate( idx, onPredicate ); - } -} - - -// EXPORTS // - -module.exports = whileAsync; diff --git a/package.json b/package.json index 2ab9171..fec327b 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Invoke a function while a test condition is true.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/math-base-assert-is-nan": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.1", - "@stdlib/string-repeat": "^0.2.1", - "@stdlib/utils-noop": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..a6615ea --- /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 78d0688..0000000 --- a/test/test.js +++ /dev/null @@ -1,328 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 whileAsync = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof whileAsync, 'function', 'main export is a function' ); - t.end(); -}); - -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() { - whileAsync( value, noop, 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() { - whileAsync( noop, value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a callback 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() { - whileAsync( noop, noop, value ); - }; - } -}); - -tape( 'while a test condition is true, the function invokes a provided function', function test( t ) { - var indices1 = [ 0, 1, 2, 3, 4, 5 ]; - var indices2 = [ 0, 1, 2, 3, 4 ]; - var j = -1; - var k = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices1[ j ], 'provides expected value' ); - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - k += 1; - t.strictEqual( i, indices2[ k ], 'provides expected value' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'while a test condition is true, the function invokes a provided function (always false)', function test( t ) { - var indices = [ 0 ]; - var j = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices[ j ], 'provides expected value' ); - clbk( null, false ); - } - - function fcn( i, next ) { - t.fail( 'should never be invoked' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx = { - 'count': 0 - }; - - whileAsync( predicate, fcn, done, ctx ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - this.count += 1; // eslint-disable-line no-invalid-this - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( ctx.count, 5, 'updates context' ); - t.end(); - } -}); - -tape( 'the function provides any results to a `done` callback', function test( t ) { - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, 'beep'+i, 'boop'+i, 'woot'+i ); - } - } - - function done( error, str1, str2, str3 ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( str1, 'beep4', 'returns expected value' ); - t.strictEqual( str2, 'boop4', 'returns expected value' ); - t.strictEqual( str3, 'woot4', 'returns expected value' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the predicate function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - if ( i === 1 ) { - return clbk( new Error( 'beep' ) ); - } - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 2, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the provided function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - if ( i === 2 ) { - return next( new Error( 'boop' ) ); - } - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 3, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'the function does not guarantee asynchronous execution', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - k = 1; - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - next(); - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( k, 0, 'releases the zalgo' ); - t.end(); - } -}); From 6365747492e301d6cf49d93823e2400277082268 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 May 2024 01:22:01 +0000 Subject: [PATCH 106/143] 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 1dafc2a..c1bab44 100644 --- a/lib/main.js +++ b/lib/main.js @@ -21,7 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -62,13 +62,13 @@ function whileAsync( predicate, fcn, done, thisArg ) { var args; var idx; if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '1Rr3c', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '1Rr2H', fcn ) ); } if ( !isFunction( done ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', done ) ); + throw new TypeError( format( '1Rr3N', done ) ); } args = []; idx = 0; diff --git a/package.json b/package.json index c943fbd..2ab9171 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ }, "dependencies": { "@stdlib/assert-is-function": "^0.2.1", - "@stdlib/string-format": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1", "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { From 19a5013c615ccd596dfb9e4a93c5fdc6657468ee Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 May 2024 02:45:36 +0000 Subject: [PATCH 107/143] Remove files --- index.d.ts | 127 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4974 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 163e8ba..0000000 --- a/index.d.ts +++ /dev/null @@ -1,127 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Callback function. -*/ -type Nullary = () => void; - -/** -* Callback function. -* -* @param error - encountered error or null -*/ -type Unary = ( error: Error | null ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Binary = ( error: Error | null, bool: boolean ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Callback = Nullary | Unary | Binary; - -/** -* Callback invoked upon completion. -*/ -type DoneNullary = () => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -*/ -type DoneUnary = ( error: Error | null ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneBinary = ( error: Error | null, ...args: Array ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneCallback = DoneNullary | DoneUnary | DoneBinary; - -/** -* Checks whether an element in a collection passes a test. -* -* @param i - iteration number (starting from one) -* @param clbk - a callback indicating whether to invoke `fcn` -*/ -type Predicate = ( i: number, clbk: Callback ) => void; - -/** -* Invoked function. -* -* @param i - iteration number (starting from zero) -* @param next - a callback which must be invoked before proceeding to the next iteration -*/ -type Fcn = ( i: number, next: Function ) => void; - -/** -* Invokes a function while a test condition is true. -* -* @param predicate - function which indicates whether to continue invoking a function -* @param fcn - function to invoke -* @param done - callback to invoke upon completion -* @param thisArg - execution context for the invoked function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -declare function whileAsync( predicate: Predicate, fcn: Fcn, done: DoneCallback, thisArg?: any ): void; - - -// EXPORTS // - -export = whileAsync; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 5136fa0..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-function@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function n(n,e,o,i){var s,l;if(!r(n))throw new TypeError(t("1Rr3c",n));if(!r(e))throw new TypeError(t("1Rr2H",e));if(!r(o))throw new TypeError(t("1Rr3N",o));function f(r,t){return r?o(r):t?e.call(i,l,h):(s.length&&s.unshift(null),void o.apply(null,s))}function h(r){var t;if(r)return o(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;8LA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index a6615ea..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 21e461c4a07b7453edb2e3148749bc9a1333b19c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 May 2024 02:45:50 +0000 Subject: [PATCH 108/143] 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 | 248 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 105 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 72 - docs/types/test.ts | 83 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 57 - lib/main.js | 128 - package.json | 57 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 328 -- 43 files changed, 4867 insertions(+), 4184 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 (100%) 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 7a8ec5e..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-05-01T01:01:25.417Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 0f8dec8..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/async/while) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 9633c26..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/async/while) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 0bdf3fd..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: '8 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' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f92a6c5..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -292,7 +283,7 @@ whileAsync( predicate, fcn, done ); ## 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]. @@ -357,13 +348,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until +[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until/tree/esm -[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while +[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while/tree/esm -[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until +[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until/tree/esm -[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while +[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while/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 7c83acf..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var whileAsync = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); - -bench( pkg+'::sync_predicate', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2c3ed87..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/async/while" -%% click B href "https://github.com/stdlib-js/utils-async-while/tree/main" -%% click C href "https://github.com/stdlib-js/utils-async-while/tree/production" -%% click D href "https://github.com/stdlib-js/utils-async-while/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-async-while/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-async-while/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/async/while -[production-url]: https://github.com/stdlib-js/utils-async-while/tree/production -[deno-url]: https://github.com/stdlib-js/utils-async-while/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-async-while/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-async-while/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-async-while/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-async-while/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-async-while/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 efdafdf..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import whileAsync from '../docs/types/index'; -export = whileAsync; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 159efee..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var v=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var m=v(function(p,g){ -var s=require('@stdlib/assert-is-function/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist');function c(t,r,e,o){var u,i;if(!s(t))throw new TypeError(l('1Rr3c',t));if(!s(r))throw new TypeError(l('1Rr2H',r));if(!s(e))throw new TypeError(l('1Rr3N',e));u=[],i=0,t(i,f);function f(a,n){if(a)return e(a);if(n)return r.call(o,i,h);u.length&&u.unshift(null),e.apply(null,u)}function h(a){var n;if(a)return e(a);if(i+=1,arguments.length>1)for(u=new Array(arguments.length-1),n=1;n 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = whileAsync;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Invoke a function while a test condition is true.\n*\n* @module @stdlib/utils-async-while\n*\n* @example\n* var whileAsync = require( '@stdlib/utils-async-while' );\n*\n* function predicate( i, clbk ) {\n* clbk( null, i < 5 );\n* }\n*\n* function fcn( i, next ) {\n* setTimeout( onTimeout, i );\n* function onTimeout() {\n* console.log( 'beep: %d', i );\n* next();\n* }\n* }\n*\n* function done( error ) {\n* if ( error ) {\n* throw error;\n* }\n* }\n*\n* whileAsync( predicate, fcn, done );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAS,QAAS,uBAAwB,EAqC9C,SAASC,EAAYC,EAAWC,EAAKC,EAAMC,EAAU,CACpD,IAAIC,EACAC,EACJ,GAAK,CAACR,EAAYG,CAAU,EAC3B,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAU,CAAE,EAE/G,GAAK,CAACH,EAAYI,CAAI,EACrB,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAI,CAAE,EAE1G,GAAK,CAACJ,EAAYK,CAAK,EACtB,MAAM,IAAI,UAAWJ,EAAQ,oEAAqEI,CAAK,CAAE,EAE1GE,EAAO,CAAC,EACRC,EAAM,EACNL,EAAWK,EAAKC,CAAY,EAU5B,SAASA,EAAaC,EAAOC,EAAS,CACrC,GAAKD,EACJ,OAAOL,EAAMK,CAAM,EAEpB,GAAKC,EACJ,OAAOP,EAAI,KAAME,EAASE,EAAKI,CAAK,EAEhCL,EAAK,QACTA,EAAK,QAAS,IAAK,EAEpBF,EAAK,MAAO,KAAME,CAAK,CACxB,CAUA,SAASK,EAAMF,EAAQ,CACtB,IAAIG,EACJ,GAAKH,EACJ,OAAOL,EAAMK,CAAM,EAKpB,GAHAF,GAAO,EAGF,UAAU,OAAS,EAEvB,IADAD,EAAO,IAAI,MAAO,UAAU,OAAO,CAAE,EAC/BM,EAAI,EAAGA,EAAI,UAAU,OAAQA,IAClCN,EAAMM,EAAE,CAAE,EAAI,UAAWA,CAAE,EAI7BV,EAAWK,EAAKC,CAAY,CAC7B,CACD,CAKAV,EAAO,QAAUG,IC5EjB,IAAIY,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "format", "whileAsync", "predicate", "fcn", "done", "thisArg", "args", "idx", "onPredicate", "error", "result", "next", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index d7ca8c9..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,72 +0,0 @@ - -{{alias}}( predicate, fcn, done[, thisArg] ) - Invokes a function while a test condition is true. - - The predicate function is provided two arguments: - - - `i`: iteration number (starting from zero) - - `clbk`: a callback indicating whether to invoke `fcn` - - The `clbk` function accepts two arguments: - - - `error`: error argument - - `bool`: test result - - If the test result is truthy, the function invokes `fcn`; otherwise, the - function invokes the `done` callback. - - The function to invoke is provided two arguments: - - - `i`: iteration number (starting from zero) - - `next`: a callback which must be invoked before proceeding to the next - iteration - - The first argument of the `next` callback is an `error` argument. If `fcn` - calls the `next` callback with a truthy `error` argument, the function - suspends execution and immediately calls the `done` callback for subsequent - `error` handling. - - The `done` callback is invoked with an `error` argument and any arguments - passed to the final `next` callback. - - Execution is *not* guaranteed to be asynchronous. To guarantee asynchrony, - wrap the `done` callback in a function which either executes at the end of - the current stack (e.g., `nextTick`) or during a subsequent turn of the - event loop (e.g., `setImmediate`, `setTimeout`). - - Parameters - ---------- - predicate: Function - The predicate function which indicates whether to continue invoking a - function. - - fcn: Function - The function to invoke. - - done: Function - Callback to invoke upon completion. - - thisArg: any (optional) - Execution context for the invoked function. - - Examples - -------- - > function predicate( i, clbk ) { clbk( null, i < 5 ); }; - > function fcn( i, next ) { - ... setTimeout( onTimeout, i ); - ... function onTimeout() { - ... next( null, 'boop'+i ); - ... } - ... }; - > function done( error, result ) { - ... if ( error ) { - ... throw error; - ... } - ... console.log( result ); - ... }; - > {{alias}}( predicate, fcn, done ) - boop: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4a543d9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,83 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 whileAsync = require( './index' ); - -const fcn = ( i: number, next: Function ): void => { - if ( i === void 0 ) { - throw new Error( '`i` is missing.' ); - } - next(); -}; - -const predicate = ( i: number, clbk: Function ): void => { - clbk( null, i < 5 ); -}; - -const done = ( error: Error | null ): void => { - if ( error ) { - throw error; - } -}; - - -// TESTS // - -// The function returns void... -{ - whileAsync( predicate, fcn, done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a predicate function... -{ - whileAsync( 2, fcn, done ); // $ExpectError - whileAsync( false, fcn, done ); // $ExpectError - whileAsync( true, fcn, done ); // $ExpectError - whileAsync( 'abc', fcn, done ); // $ExpectError - whileAsync( {}, fcn, done ); // $ExpectError - whileAsync( [], fcn, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function having a supported signature... -{ - whileAsync( predicate, 2, done ); // $ExpectError - whileAsync( predicate, false, done ); // $ExpectError - whileAsync( predicate, true, done ); // $ExpectError - whileAsync( predicate, 'abc', done ); // $ExpectError - whileAsync( predicate, {}, done ); // $ExpectError - whileAsync( predicate, [], done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a done callback argument which is not a function having a supported signature... -{ - whileAsync( predicate, fcn, 2 ); // $ExpectError - whileAsync( predicate, fcn, false ); // $ExpectError - whileAsync( predicate, fcn, true ); // $ExpectError - whileAsync( predicate, fcn, 'abc' ); // $ExpectError - whileAsync( predicate, fcn, {} ); // $ExpectError - whileAsync( predicate, fcn, [] ); // $ExpectError - whileAsync( predicate, fcn, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - whileAsync(); // $ExpectError - whileAsync( predicate ); // $ExpectError - whileAsync( predicate, fcn ); // $ExpectError - whileAsync( predicate, fcn, done, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a6af668..0000000 --- a/examples/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var repeatString = require( '@stdlib/string-repeat' ); -var whileAsync = require( './../lib' ); - -function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } -} - -function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, repeatString( 'beep', i+1 ) ); - } -} - -function done( error, result ) { - if ( error ) { - throw error; - } - console.log( result ); -} - -whileAsync( predicate, fcn, done ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..5136fa0 --- /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-function@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function n(n,e,o,i){var s,l;if(!r(n))throw new TypeError(t("1Rr3c",n));if(!r(e))throw new TypeError(t("1Rr2H",e));if(!r(o))throw new TypeError(t("1Rr3N",o));function f(r,t){return r?o(r):t?e.call(i,l,h):(s.length&&s.unshift(null),void o.apply(null,s))}function h(r){var t;if(r)return o(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;8LA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a13bd4..0000000 --- a/lib/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Invoke a function while a test condition is true. -* -* @module @stdlib/utils-async-while -* -* @example -* var whileAsync = require( '@stdlib/utils-async-while' ); -* -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c1bab44..0000000 --- a/lib/main.js +++ /dev/null @@ -1,128 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Invokes a function while a test condition is true. -* -* @param {Function} predicate - function which indicates whether to continue invoking a function -* @param {Function} fcn - function to invoke -* @param {Callback} done - callback to invoke upon completion -* @param {*} [thisArg] - execution context for the invoked function -* @throws {TypeError} first argument must be a function -* @throws {TypeError} second argument must be a function -* @throws {TypeError} third argument must be a function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -function whileAsync( predicate, fcn, done, thisArg ) { - var args; - var idx; - if ( !isFunction( predicate ) ) { - throw new TypeError( format( '1Rr3c', predicate ) ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '1Rr2H', fcn ) ); - } - if ( !isFunction( done ) ) { - throw new TypeError( format( '1Rr3N', done ) ); - } - args = []; - idx = 0; - predicate( idx, onPredicate ); - - /** - * Callback invoked upon a predicate result. - * - * @private - * @param {(Error|null)} error - error object - * @param {boolean} result - predicate result - * @returns {void} - */ - function onPredicate( error, result ) { - if ( error ) { - return done( error ); - } - if ( result ) { - return fcn.call( thisArg, idx, next ); - } - if ( args.length ) { - args.unshift( null ); // error argument - } - done.apply( null, args ); - } - - /** - * Callback invoked upon completion of a provided function. - * - * @private - * @param {(Error|null)} error - error object - * @param {...*} results - function results - * @returns {void} - */ - function next( error ) { - var i; - if ( error ) { - return done( error ); - } - idx += 1; - - // Cache the most recent results... - if ( arguments.length > 1 ) { - args = new Array( arguments.length-1 ); - for ( i = 1; i < arguments.length; i++ ) { - args[ i-1 ] = arguments[ i ]; - } - } - // Run the test condition: - predicate( idx, onPredicate ); - } -} - - -// EXPORTS // - -module.exports = whileAsync; diff --git a/package.json b/package.json index 2ab9171..fec327b 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Invoke a function while a test condition is true.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/math-base-assert-is-nan": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.1", - "@stdlib/string-repeat": "^0.2.1", - "@stdlib/utils-noop": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..a6615ea --- /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 78d0688..0000000 --- a/test/test.js +++ /dev/null @@ -1,328 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 whileAsync = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof whileAsync, 'function', 'main export is a function' ); - t.end(); -}); - -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() { - whileAsync( value, noop, 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() { - whileAsync( noop, value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a callback 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() { - whileAsync( noop, noop, value ); - }; - } -}); - -tape( 'while a test condition is true, the function invokes a provided function', function test( t ) { - var indices1 = [ 0, 1, 2, 3, 4, 5 ]; - var indices2 = [ 0, 1, 2, 3, 4 ]; - var j = -1; - var k = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices1[ j ], 'provides expected value' ); - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - k += 1; - t.strictEqual( i, indices2[ k ], 'provides expected value' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'while a test condition is true, the function invokes a provided function (always false)', function test( t ) { - var indices = [ 0 ]; - var j = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices[ j ], 'provides expected value' ); - clbk( null, false ); - } - - function fcn( i, next ) { - t.fail( 'should never be invoked' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx = { - 'count': 0 - }; - - whileAsync( predicate, fcn, done, ctx ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - this.count += 1; // eslint-disable-line no-invalid-this - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( ctx.count, 5, 'updates context' ); - t.end(); - } -}); - -tape( 'the function provides any results to a `done` callback', function test( t ) { - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, 'beep'+i, 'boop'+i, 'woot'+i ); - } - } - - function done( error, str1, str2, str3 ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( str1, 'beep4', 'returns expected value' ); - t.strictEqual( str2, 'boop4', 'returns expected value' ); - t.strictEqual( str3, 'woot4', 'returns expected value' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the predicate function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - if ( i === 1 ) { - return clbk( new Error( 'beep' ) ); - } - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 2, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the provided function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - if ( i === 2 ) { - return next( new Error( 'boop' ) ); - } - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 3, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'the function does not guarantee asynchronous execution', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - k = 1; - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - next(); - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( k, 0, 'releases the zalgo' ); - t.end(); - } -}); From 2913c75f710e5ecbf2f825796138cbea6788f44f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jun 2024 01:27:19 +0000 Subject: [PATCH 109/143] 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 1dafc2a..c1bab44 100644 --- a/lib/main.js +++ b/lib/main.js @@ -21,7 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -62,13 +62,13 @@ function whileAsync( predicate, fcn, done, thisArg ) { var args; var idx; if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '1Rr3c', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '1Rr2H', fcn ) ); } if ( !isFunction( done ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', done ) ); + throw new TypeError( format( '1Rr3N', done ) ); } args = []; idx = 0; diff --git a/package.json b/package.json index c943fbd..2ab9171 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ }, "dependencies": { "@stdlib/assert-is-function": "^0.2.1", - "@stdlib/string-format": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1", "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { From 1cafd3fcb2fb17a6f469b464e509ea31af408d0c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jun 2024 02:41:19 +0000 Subject: [PATCH 110/143] Remove files --- index.d.ts | 127 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4974 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 163e8ba..0000000 --- a/index.d.ts +++ /dev/null @@ -1,127 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Callback function. -*/ -type Nullary = () => void; - -/** -* Callback function. -* -* @param error - encountered error or null -*/ -type Unary = ( error: Error | null ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Binary = ( error: Error | null, bool: boolean ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Callback = Nullary | Unary | Binary; - -/** -* Callback invoked upon completion. -*/ -type DoneNullary = () => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -*/ -type DoneUnary = ( error: Error | null ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneBinary = ( error: Error | null, ...args: Array ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneCallback = DoneNullary | DoneUnary | DoneBinary; - -/** -* Checks whether an element in a collection passes a test. -* -* @param i - iteration number (starting from one) -* @param clbk - a callback indicating whether to invoke `fcn` -*/ -type Predicate = ( i: number, clbk: Callback ) => void; - -/** -* Invoked function. -* -* @param i - iteration number (starting from zero) -* @param next - a callback which must be invoked before proceeding to the next iteration -*/ -type Fcn = ( i: number, next: Function ) => void; - -/** -* Invokes a function while a test condition is true. -* -* @param predicate - function which indicates whether to continue invoking a function -* @param fcn - function to invoke -* @param done - callback to invoke upon completion -* @param thisArg - execution context for the invoked function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -declare function whileAsync( predicate: Predicate, fcn: Fcn, done: DoneCallback, thisArg?: any ): void; - - -// EXPORTS // - -export = whileAsync; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 5136fa0..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-function@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function n(n,e,o,i){var s,l;if(!r(n))throw new TypeError(t("1Rr3c",n));if(!r(e))throw new TypeError(t("1Rr2H",e));if(!r(o))throw new TypeError(t("1Rr3N",o));function f(r,t){return r?o(r):t?e.call(i,l,h):(s.length&&s.unshift(null),void o.apply(null,s))}function h(r){var t;if(r)return o(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;8LA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index a6615ea..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 10d13d5c63f44577641679ad028174993a0faffd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jun 2024 02:41:35 +0000 Subject: [PATCH 111/143] 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 | 248 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 105 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 72 - docs/types/test.ts | 83 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 57 - lib/main.js | 128 - package.json | 57 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 328 -- 43 files changed, 4867 insertions(+), 4184 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 (100%) 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 08ac8a2..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-06-01T01:09:26.510Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 0f8dec8..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/async/while) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 9633c26..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/async/while) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 0bdf3fd..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: '8 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' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f92a6c5..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -292,7 +283,7 @@ whileAsync( predicate, fcn, done ); ## 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]. @@ -357,13 +348,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until +[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until/tree/esm -[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while +[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while/tree/esm -[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until +[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until/tree/esm -[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while +[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while/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 7c83acf..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var whileAsync = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); - -bench( pkg+'::sync_predicate', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2c3ed87..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/async/while" -%% click B href "https://github.com/stdlib-js/utils-async-while/tree/main" -%% click C href "https://github.com/stdlib-js/utils-async-while/tree/production" -%% click D href "https://github.com/stdlib-js/utils-async-while/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-async-while/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-async-while/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/async/while -[production-url]: https://github.com/stdlib-js/utils-async-while/tree/production -[deno-url]: https://github.com/stdlib-js/utils-async-while/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-async-while/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-async-while/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-async-while/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-async-while/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-async-while/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 efdafdf..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import whileAsync from '../docs/types/index'; -export = whileAsync; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 159efee..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var v=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var m=v(function(p,g){ -var s=require('@stdlib/assert-is-function/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist');function c(t,r,e,o){var u,i;if(!s(t))throw new TypeError(l('1Rr3c',t));if(!s(r))throw new TypeError(l('1Rr2H',r));if(!s(e))throw new TypeError(l('1Rr3N',e));u=[],i=0,t(i,f);function f(a,n){if(a)return e(a);if(n)return r.call(o,i,h);u.length&&u.unshift(null),e.apply(null,u)}function h(a){var n;if(a)return e(a);if(i+=1,arguments.length>1)for(u=new Array(arguments.length-1),n=1;n 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = whileAsync;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Invoke a function while a test condition is true.\n*\n* @module @stdlib/utils-async-while\n*\n* @example\n* var whileAsync = require( '@stdlib/utils-async-while' );\n*\n* function predicate( i, clbk ) {\n* clbk( null, i < 5 );\n* }\n*\n* function fcn( i, next ) {\n* setTimeout( onTimeout, i );\n* function onTimeout() {\n* console.log( 'beep: %d', i );\n* next();\n* }\n* }\n*\n* function done( error ) {\n* if ( error ) {\n* throw error;\n* }\n* }\n*\n* whileAsync( predicate, fcn, done );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAS,QAAS,uBAAwB,EAqC9C,SAASC,EAAYC,EAAWC,EAAKC,EAAMC,EAAU,CACpD,IAAIC,EACAC,EACJ,GAAK,CAACR,EAAYG,CAAU,EAC3B,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAU,CAAE,EAE/G,GAAK,CAACH,EAAYI,CAAI,EACrB,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAI,CAAE,EAE1G,GAAK,CAACJ,EAAYK,CAAK,EACtB,MAAM,IAAI,UAAWJ,EAAQ,oEAAqEI,CAAK,CAAE,EAE1GE,EAAO,CAAC,EACRC,EAAM,EACNL,EAAWK,EAAKC,CAAY,EAU5B,SAASA,EAAaC,EAAOC,EAAS,CACrC,GAAKD,EACJ,OAAOL,EAAMK,CAAM,EAEpB,GAAKC,EACJ,OAAOP,EAAI,KAAME,EAASE,EAAKI,CAAK,EAEhCL,EAAK,QACTA,EAAK,QAAS,IAAK,EAEpBF,EAAK,MAAO,KAAME,CAAK,CACxB,CAUA,SAASK,EAAMF,EAAQ,CACtB,IAAIG,EACJ,GAAKH,EACJ,OAAOL,EAAMK,CAAM,EAKpB,GAHAF,GAAO,EAGF,UAAU,OAAS,EAEvB,IADAD,EAAO,IAAI,MAAO,UAAU,OAAO,CAAE,EAC/BM,EAAI,EAAGA,EAAI,UAAU,OAAQA,IAClCN,EAAMM,EAAE,CAAE,EAAI,UAAWA,CAAE,EAI7BV,EAAWK,EAAKC,CAAY,CAC7B,CACD,CAKAV,EAAO,QAAUG,IC5EjB,IAAIY,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "format", "whileAsync", "predicate", "fcn", "done", "thisArg", "args", "idx", "onPredicate", "error", "result", "next", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index d7ca8c9..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,72 +0,0 @@ - -{{alias}}( predicate, fcn, done[, thisArg] ) - Invokes a function while a test condition is true. - - The predicate function is provided two arguments: - - - `i`: iteration number (starting from zero) - - `clbk`: a callback indicating whether to invoke `fcn` - - The `clbk` function accepts two arguments: - - - `error`: error argument - - `bool`: test result - - If the test result is truthy, the function invokes `fcn`; otherwise, the - function invokes the `done` callback. - - The function to invoke is provided two arguments: - - - `i`: iteration number (starting from zero) - - `next`: a callback which must be invoked before proceeding to the next - iteration - - The first argument of the `next` callback is an `error` argument. If `fcn` - calls the `next` callback with a truthy `error` argument, the function - suspends execution and immediately calls the `done` callback for subsequent - `error` handling. - - The `done` callback is invoked with an `error` argument and any arguments - passed to the final `next` callback. - - Execution is *not* guaranteed to be asynchronous. To guarantee asynchrony, - wrap the `done` callback in a function which either executes at the end of - the current stack (e.g., `nextTick`) or during a subsequent turn of the - event loop (e.g., `setImmediate`, `setTimeout`). - - Parameters - ---------- - predicate: Function - The predicate function which indicates whether to continue invoking a - function. - - fcn: Function - The function to invoke. - - done: Function - Callback to invoke upon completion. - - thisArg: any (optional) - Execution context for the invoked function. - - Examples - -------- - > function predicate( i, clbk ) { clbk( null, i < 5 ); }; - > function fcn( i, next ) { - ... setTimeout( onTimeout, i ); - ... function onTimeout() { - ... next( null, 'boop'+i ); - ... } - ... }; - > function done( error, result ) { - ... if ( error ) { - ... throw error; - ... } - ... console.log( result ); - ... }; - > {{alias}}( predicate, fcn, done ) - boop: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4a543d9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,83 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 whileAsync = require( './index' ); - -const fcn = ( i: number, next: Function ): void => { - if ( i === void 0 ) { - throw new Error( '`i` is missing.' ); - } - next(); -}; - -const predicate = ( i: number, clbk: Function ): void => { - clbk( null, i < 5 ); -}; - -const done = ( error: Error | null ): void => { - if ( error ) { - throw error; - } -}; - - -// TESTS // - -// The function returns void... -{ - whileAsync( predicate, fcn, done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a predicate function... -{ - whileAsync( 2, fcn, done ); // $ExpectError - whileAsync( false, fcn, done ); // $ExpectError - whileAsync( true, fcn, done ); // $ExpectError - whileAsync( 'abc', fcn, done ); // $ExpectError - whileAsync( {}, fcn, done ); // $ExpectError - whileAsync( [], fcn, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function having a supported signature... -{ - whileAsync( predicate, 2, done ); // $ExpectError - whileAsync( predicate, false, done ); // $ExpectError - whileAsync( predicate, true, done ); // $ExpectError - whileAsync( predicate, 'abc', done ); // $ExpectError - whileAsync( predicate, {}, done ); // $ExpectError - whileAsync( predicate, [], done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a done callback argument which is not a function having a supported signature... -{ - whileAsync( predicate, fcn, 2 ); // $ExpectError - whileAsync( predicate, fcn, false ); // $ExpectError - whileAsync( predicate, fcn, true ); // $ExpectError - whileAsync( predicate, fcn, 'abc' ); // $ExpectError - whileAsync( predicate, fcn, {} ); // $ExpectError - whileAsync( predicate, fcn, [] ); // $ExpectError - whileAsync( predicate, fcn, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - whileAsync(); // $ExpectError - whileAsync( predicate ); // $ExpectError - whileAsync( predicate, fcn ); // $ExpectError - whileAsync( predicate, fcn, done, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a6af668..0000000 --- a/examples/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var repeatString = require( '@stdlib/string-repeat' ); -var whileAsync = require( './../lib' ); - -function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } -} - -function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, repeatString( 'beep', i+1 ) ); - } -} - -function done( error, result ) { - if ( error ) { - throw error; - } - console.log( result ); -} - -whileAsync( predicate, fcn, done ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..5136fa0 --- /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-function@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function n(n,e,o,i){var s,l;if(!r(n))throw new TypeError(t("1Rr3c",n));if(!r(e))throw new TypeError(t("1Rr2H",e));if(!r(o))throw new TypeError(t("1Rr3N",o));function f(r,t){return r?o(r):t?e.call(i,l,h):(s.length&&s.unshift(null),void o.apply(null,s))}function h(r){var t;if(r)return o(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;8LA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a13bd4..0000000 --- a/lib/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Invoke a function while a test condition is true. -* -* @module @stdlib/utils-async-while -* -* @example -* var whileAsync = require( '@stdlib/utils-async-while' ); -* -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c1bab44..0000000 --- a/lib/main.js +++ /dev/null @@ -1,128 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Invokes a function while a test condition is true. -* -* @param {Function} predicate - function which indicates whether to continue invoking a function -* @param {Function} fcn - function to invoke -* @param {Callback} done - callback to invoke upon completion -* @param {*} [thisArg] - execution context for the invoked function -* @throws {TypeError} first argument must be a function -* @throws {TypeError} second argument must be a function -* @throws {TypeError} third argument must be a function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -function whileAsync( predicate, fcn, done, thisArg ) { - var args; - var idx; - if ( !isFunction( predicate ) ) { - throw new TypeError( format( '1Rr3c', predicate ) ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '1Rr2H', fcn ) ); - } - if ( !isFunction( done ) ) { - throw new TypeError( format( '1Rr3N', done ) ); - } - args = []; - idx = 0; - predicate( idx, onPredicate ); - - /** - * Callback invoked upon a predicate result. - * - * @private - * @param {(Error|null)} error - error object - * @param {boolean} result - predicate result - * @returns {void} - */ - function onPredicate( error, result ) { - if ( error ) { - return done( error ); - } - if ( result ) { - return fcn.call( thisArg, idx, next ); - } - if ( args.length ) { - args.unshift( null ); // error argument - } - done.apply( null, args ); - } - - /** - * Callback invoked upon completion of a provided function. - * - * @private - * @param {(Error|null)} error - error object - * @param {...*} results - function results - * @returns {void} - */ - function next( error ) { - var i; - if ( error ) { - return done( error ); - } - idx += 1; - - // Cache the most recent results... - if ( arguments.length > 1 ) { - args = new Array( arguments.length-1 ); - for ( i = 1; i < arguments.length; i++ ) { - args[ i-1 ] = arguments[ i ]; - } - } - // Run the test condition: - predicate( idx, onPredicate ); - } -} - - -// EXPORTS // - -module.exports = whileAsync; diff --git a/package.json b/package.json index 2ab9171..fec327b 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Invoke a function while a test condition is true.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/math-base-assert-is-nan": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.1", - "@stdlib/string-repeat": "^0.2.1", - "@stdlib/utils-noop": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..a6615ea --- /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 78d0688..0000000 --- a/test/test.js +++ /dev/null @@ -1,328 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 whileAsync = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof whileAsync, 'function', 'main export is a function' ); - t.end(); -}); - -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() { - whileAsync( value, noop, 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() { - whileAsync( noop, value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a callback 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() { - whileAsync( noop, noop, value ); - }; - } -}); - -tape( 'while a test condition is true, the function invokes a provided function', function test( t ) { - var indices1 = [ 0, 1, 2, 3, 4, 5 ]; - var indices2 = [ 0, 1, 2, 3, 4 ]; - var j = -1; - var k = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices1[ j ], 'provides expected value' ); - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - k += 1; - t.strictEqual( i, indices2[ k ], 'provides expected value' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'while a test condition is true, the function invokes a provided function (always false)', function test( t ) { - var indices = [ 0 ]; - var j = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices[ j ], 'provides expected value' ); - clbk( null, false ); - } - - function fcn( i, next ) { - t.fail( 'should never be invoked' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx = { - 'count': 0 - }; - - whileAsync( predicate, fcn, done, ctx ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - this.count += 1; // eslint-disable-line no-invalid-this - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( ctx.count, 5, 'updates context' ); - t.end(); - } -}); - -tape( 'the function provides any results to a `done` callback', function test( t ) { - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, 'beep'+i, 'boop'+i, 'woot'+i ); - } - } - - function done( error, str1, str2, str3 ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( str1, 'beep4', 'returns expected value' ); - t.strictEqual( str2, 'boop4', 'returns expected value' ); - t.strictEqual( str3, 'woot4', 'returns expected value' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the predicate function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - if ( i === 1 ) { - return clbk( new Error( 'beep' ) ); - } - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 2, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the provided function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - if ( i === 2 ) { - return next( new Error( 'boop' ) ); - } - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 3, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'the function does not guarantee asynchronous execution', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - k = 1; - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - next(); - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( k, 0, 'releases the zalgo' ); - t.end(); - } -}); From 1563f7cc4452a738f052b75dccf675fca44ed420 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jul 2024 01:26:13 +0000 Subject: [PATCH 112/143] 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 1dafc2a..c1bab44 100644 --- a/lib/main.js +++ b/lib/main.js @@ -21,7 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -62,13 +62,13 @@ function whileAsync( predicate, fcn, done, thisArg ) { var args; var idx; if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '1Rr3c', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '1Rr2H', fcn ) ); } if ( !isFunction( done ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', done ) ); + throw new TypeError( format( '1Rr3N', done ) ); } args = []; idx = 0; diff --git a/package.json b/package.json index c943fbd..2ab9171 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ }, "dependencies": { "@stdlib/assert-is-function": "^0.2.1", - "@stdlib/string-format": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1", "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { From 2d8848604fa8c318fa54f22a9595cde8a5d7ea5d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jul 2024 02:43:47 +0000 Subject: [PATCH 113/143] Remove files --- index.d.ts | 127 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4974 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 163e8ba..0000000 --- a/index.d.ts +++ /dev/null @@ -1,127 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Callback function. -*/ -type Nullary = () => void; - -/** -* Callback function. -* -* @param error - encountered error or null -*/ -type Unary = ( error: Error | null ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Binary = ( error: Error | null, bool: boolean ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Callback = Nullary | Unary | Binary; - -/** -* Callback invoked upon completion. -*/ -type DoneNullary = () => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -*/ -type DoneUnary = ( error: Error | null ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneBinary = ( error: Error | null, ...args: Array ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneCallback = DoneNullary | DoneUnary | DoneBinary; - -/** -* Checks whether an element in a collection passes a test. -* -* @param i - iteration number (starting from one) -* @param clbk - a callback indicating whether to invoke `fcn` -*/ -type Predicate = ( i: number, clbk: Callback ) => void; - -/** -* Invoked function. -* -* @param i - iteration number (starting from zero) -* @param next - a callback which must be invoked before proceeding to the next iteration -*/ -type Fcn = ( i: number, next: Function ) => void; - -/** -* Invokes a function while a test condition is true. -* -* @param predicate - function which indicates whether to continue invoking a function -* @param fcn - function to invoke -* @param done - callback to invoke upon completion -* @param thisArg - execution context for the invoked function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -declare function whileAsync( predicate: Predicate, fcn: Fcn, done: DoneCallback, thisArg?: any ): void; - - -// EXPORTS // - -export = whileAsync; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 5136fa0..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-function@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function n(n,e,o,i){var s,l;if(!r(n))throw new TypeError(t("1Rr3c",n));if(!r(e))throw new TypeError(t("1Rr2H",e));if(!r(o))throw new TypeError(t("1Rr3N",o));function f(r,t){return r?o(r):t?e.call(i,l,h):(s.length&&s.unshift(null),void o.apply(null,s))}function h(r){var t;if(r)return o(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;8LA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index a6615ea..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 8cbe3971a311520899a33ef0f4f030e133f76207 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jul 2024 02:44:02 +0000 Subject: [PATCH 114/143] 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 | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 38 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 105 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 72 - docs/types/test.ts | 83 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 57 - lib/main.js | 128 - package.json | 57 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 328 -- 43 files changed, 4867 insertions(+), 4221 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 (100%) 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 b260da3..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-07-01T01:08:34.417Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 0f8dec8..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/async/while) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 9633c26..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/async/while) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 0bdf3fd..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: '8 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' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f92a6c5..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -292,7 +283,7 @@ whileAsync( predicate, fcn, done ); ## 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]. @@ -357,13 +348,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until +[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until/tree/esm -[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while +[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while/tree/esm -[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until +[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until/tree/esm -[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while +[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while/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 7c83acf..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var whileAsync = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); - -bench( pkg+'::sync_predicate', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2c3ed87..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/async/while" -%% click B href "https://github.com/stdlib-js/utils-async-while/tree/main" -%% click C href "https://github.com/stdlib-js/utils-async-while/tree/production" -%% click D href "https://github.com/stdlib-js/utils-async-while/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-async-while/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-async-while/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/async/while -[production-url]: https://github.com/stdlib-js/utils-async-while/tree/production -[deno-url]: https://github.com/stdlib-js/utils-async-while/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-async-while/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-async-while/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-async-while/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-async-while/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-async-while/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 efdafdf..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import whileAsync from '../docs/types/index'; -export = whileAsync; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 159efee..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var v=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var m=v(function(p,g){ -var s=require('@stdlib/assert-is-function/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist');function c(t,r,e,o){var u,i;if(!s(t))throw new TypeError(l('1Rr3c',t));if(!s(r))throw new TypeError(l('1Rr2H',r));if(!s(e))throw new TypeError(l('1Rr3N',e));u=[],i=0,t(i,f);function f(a,n){if(a)return e(a);if(n)return r.call(o,i,h);u.length&&u.unshift(null),e.apply(null,u)}function h(a){var n;if(a)return e(a);if(i+=1,arguments.length>1)for(u=new Array(arguments.length-1),n=1;n 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = whileAsync;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Invoke a function while a test condition is true.\n*\n* @module @stdlib/utils-async-while\n*\n* @example\n* var whileAsync = require( '@stdlib/utils-async-while' );\n*\n* function predicate( i, clbk ) {\n* clbk( null, i < 5 );\n* }\n*\n* function fcn( i, next ) {\n* setTimeout( onTimeout, i );\n* function onTimeout() {\n* console.log( 'beep: %d', i );\n* next();\n* }\n* }\n*\n* function done( error ) {\n* if ( error ) {\n* throw error;\n* }\n* }\n*\n* whileAsync( predicate, fcn, done );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAS,QAAS,uBAAwB,EAqC9C,SAASC,EAAYC,EAAWC,EAAKC,EAAMC,EAAU,CACpD,IAAIC,EACAC,EACJ,GAAK,CAACR,EAAYG,CAAU,EAC3B,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAU,CAAE,EAE/G,GAAK,CAACH,EAAYI,CAAI,EACrB,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAI,CAAE,EAE1G,GAAK,CAACJ,EAAYK,CAAK,EACtB,MAAM,IAAI,UAAWJ,EAAQ,oEAAqEI,CAAK,CAAE,EAE1GE,EAAO,CAAC,EACRC,EAAM,EACNL,EAAWK,EAAKC,CAAY,EAU5B,SAASA,EAAaC,EAAOC,EAAS,CACrC,GAAKD,EACJ,OAAOL,EAAMK,CAAM,EAEpB,GAAKC,EACJ,OAAOP,EAAI,KAAME,EAASE,EAAKI,CAAK,EAEhCL,EAAK,QACTA,EAAK,QAAS,IAAK,EAEpBF,EAAK,MAAO,KAAME,CAAK,CACxB,CAUA,SAASK,EAAMF,EAAQ,CACtB,IAAIG,EACJ,GAAKH,EACJ,OAAOL,EAAMK,CAAM,EAKpB,GAHAF,GAAO,EAGF,UAAU,OAAS,EAEvB,IADAD,EAAO,IAAI,MAAO,UAAU,OAAO,CAAE,EAC/BM,EAAI,EAAGA,EAAI,UAAU,OAAQA,IAClCN,EAAMM,EAAE,CAAE,EAAI,UAAWA,CAAE,EAI7BV,EAAWK,EAAKC,CAAY,CAC7B,CACD,CAKAV,EAAO,QAAUG,IC5EjB,IAAIY,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "format", "whileAsync", "predicate", "fcn", "done", "thisArg", "args", "idx", "onPredicate", "error", "result", "next", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index d7ca8c9..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,72 +0,0 @@ - -{{alias}}( predicate, fcn, done[, thisArg] ) - Invokes a function while a test condition is true. - - The predicate function is provided two arguments: - - - `i`: iteration number (starting from zero) - - `clbk`: a callback indicating whether to invoke `fcn` - - The `clbk` function accepts two arguments: - - - `error`: error argument - - `bool`: test result - - If the test result is truthy, the function invokes `fcn`; otherwise, the - function invokes the `done` callback. - - The function to invoke is provided two arguments: - - - `i`: iteration number (starting from zero) - - `next`: a callback which must be invoked before proceeding to the next - iteration - - The first argument of the `next` callback is an `error` argument. If `fcn` - calls the `next` callback with a truthy `error` argument, the function - suspends execution and immediately calls the `done` callback for subsequent - `error` handling. - - The `done` callback is invoked with an `error` argument and any arguments - passed to the final `next` callback. - - Execution is *not* guaranteed to be asynchronous. To guarantee asynchrony, - wrap the `done` callback in a function which either executes at the end of - the current stack (e.g., `nextTick`) or during a subsequent turn of the - event loop (e.g., `setImmediate`, `setTimeout`). - - Parameters - ---------- - predicate: Function - The predicate function which indicates whether to continue invoking a - function. - - fcn: Function - The function to invoke. - - done: Function - Callback to invoke upon completion. - - thisArg: any (optional) - Execution context for the invoked function. - - Examples - -------- - > function predicate( i, clbk ) { clbk( null, i < 5 ); }; - > function fcn( i, next ) { - ... setTimeout( onTimeout, i ); - ... function onTimeout() { - ... next( null, 'boop'+i ); - ... } - ... }; - > function done( error, result ) { - ... if ( error ) { - ... throw error; - ... } - ... console.log( result ); - ... }; - > {{alias}}( predicate, fcn, done ) - boop: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4a543d9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,83 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 whileAsync = require( './index' ); - -const fcn = ( i: number, next: Function ): void => { - if ( i === void 0 ) { - throw new Error( '`i` is missing.' ); - } - next(); -}; - -const predicate = ( i: number, clbk: Function ): void => { - clbk( null, i < 5 ); -}; - -const done = ( error: Error | null ): void => { - if ( error ) { - throw error; - } -}; - - -// TESTS // - -// The function returns void... -{ - whileAsync( predicate, fcn, done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a predicate function... -{ - whileAsync( 2, fcn, done ); // $ExpectError - whileAsync( false, fcn, done ); // $ExpectError - whileAsync( true, fcn, done ); // $ExpectError - whileAsync( 'abc', fcn, done ); // $ExpectError - whileAsync( {}, fcn, done ); // $ExpectError - whileAsync( [], fcn, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function having a supported signature... -{ - whileAsync( predicate, 2, done ); // $ExpectError - whileAsync( predicate, false, done ); // $ExpectError - whileAsync( predicate, true, done ); // $ExpectError - whileAsync( predicate, 'abc', done ); // $ExpectError - whileAsync( predicate, {}, done ); // $ExpectError - whileAsync( predicate, [], done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a done callback argument which is not a function having a supported signature... -{ - whileAsync( predicate, fcn, 2 ); // $ExpectError - whileAsync( predicate, fcn, false ); // $ExpectError - whileAsync( predicate, fcn, true ); // $ExpectError - whileAsync( predicate, fcn, 'abc' ); // $ExpectError - whileAsync( predicate, fcn, {} ); // $ExpectError - whileAsync( predicate, fcn, [] ); // $ExpectError - whileAsync( predicate, fcn, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - whileAsync(); // $ExpectError - whileAsync( predicate ); // $ExpectError - whileAsync( predicate, fcn ); // $ExpectError - whileAsync( predicate, fcn, done, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a6af668..0000000 --- a/examples/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var repeatString = require( '@stdlib/string-repeat' ); -var whileAsync = require( './../lib' ); - -function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } -} - -function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, repeatString( 'beep', i+1 ) ); - } -} - -function done( error, result ) { - if ( error ) { - throw error; - } - console.log( result ); -} - -whileAsync( predicate, fcn, done ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..5136fa0 --- /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-function@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function n(n,e,o,i){var s,l;if(!r(n))throw new TypeError(t("1Rr3c",n));if(!r(e))throw new TypeError(t("1Rr2H",e));if(!r(o))throw new TypeError(t("1Rr3N",o));function f(r,t){return r?o(r):t?e.call(i,l,h):(s.length&&s.unshift(null),void o.apply(null,s))}function h(r){var t;if(r)return o(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;8LA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a13bd4..0000000 --- a/lib/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Invoke a function while a test condition is true. -* -* @module @stdlib/utils-async-while -* -* @example -* var whileAsync = require( '@stdlib/utils-async-while' ); -* -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c1bab44..0000000 --- a/lib/main.js +++ /dev/null @@ -1,128 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Invokes a function while a test condition is true. -* -* @param {Function} predicate - function which indicates whether to continue invoking a function -* @param {Function} fcn - function to invoke -* @param {Callback} done - callback to invoke upon completion -* @param {*} [thisArg] - execution context for the invoked function -* @throws {TypeError} first argument must be a function -* @throws {TypeError} second argument must be a function -* @throws {TypeError} third argument must be a function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -function whileAsync( predicate, fcn, done, thisArg ) { - var args; - var idx; - if ( !isFunction( predicate ) ) { - throw new TypeError( format( '1Rr3c', predicate ) ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '1Rr2H', fcn ) ); - } - if ( !isFunction( done ) ) { - throw new TypeError( format( '1Rr3N', done ) ); - } - args = []; - idx = 0; - predicate( idx, onPredicate ); - - /** - * Callback invoked upon a predicate result. - * - * @private - * @param {(Error|null)} error - error object - * @param {boolean} result - predicate result - * @returns {void} - */ - function onPredicate( error, result ) { - if ( error ) { - return done( error ); - } - if ( result ) { - return fcn.call( thisArg, idx, next ); - } - if ( args.length ) { - args.unshift( null ); // error argument - } - done.apply( null, args ); - } - - /** - * Callback invoked upon completion of a provided function. - * - * @private - * @param {(Error|null)} error - error object - * @param {...*} results - function results - * @returns {void} - */ - function next( error ) { - var i; - if ( error ) { - return done( error ); - } - idx += 1; - - // Cache the most recent results... - if ( arguments.length > 1 ) { - args = new Array( arguments.length-1 ); - for ( i = 1; i < arguments.length; i++ ) { - args[ i-1 ] = arguments[ i ]; - } - } - // Run the test condition: - predicate( idx, onPredicate ); - } -} - - -// EXPORTS // - -module.exports = whileAsync; diff --git a/package.json b/package.json index 2ab9171..fec327b 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Invoke a function while a test condition is true.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/math-base-assert-is-nan": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.1", - "@stdlib/string-repeat": "^0.2.1", - "@stdlib/utils-noop": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..a6615ea --- /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 78d0688..0000000 --- a/test/test.js +++ /dev/null @@ -1,328 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 whileAsync = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof whileAsync, 'function', 'main export is a function' ); - t.end(); -}); - -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() { - whileAsync( value, noop, 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() { - whileAsync( noop, value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a callback 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() { - whileAsync( noop, noop, value ); - }; - } -}); - -tape( 'while a test condition is true, the function invokes a provided function', function test( t ) { - var indices1 = [ 0, 1, 2, 3, 4, 5 ]; - var indices2 = [ 0, 1, 2, 3, 4 ]; - var j = -1; - var k = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices1[ j ], 'provides expected value' ); - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - k += 1; - t.strictEqual( i, indices2[ k ], 'provides expected value' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'while a test condition is true, the function invokes a provided function (always false)', function test( t ) { - var indices = [ 0 ]; - var j = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices[ j ], 'provides expected value' ); - clbk( null, false ); - } - - function fcn( i, next ) { - t.fail( 'should never be invoked' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx = { - 'count': 0 - }; - - whileAsync( predicate, fcn, done, ctx ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - this.count += 1; // eslint-disable-line no-invalid-this - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( ctx.count, 5, 'updates context' ); - t.end(); - } -}); - -tape( 'the function provides any results to a `done` callback', function test( t ) { - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, 'beep'+i, 'boop'+i, 'woot'+i ); - } - } - - function done( error, str1, str2, str3 ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( str1, 'beep4', 'returns expected value' ); - t.strictEqual( str2, 'boop4', 'returns expected value' ); - t.strictEqual( str3, 'woot4', 'returns expected value' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the predicate function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - if ( i === 1 ) { - return clbk( new Error( 'beep' ) ); - } - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 2, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the provided function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - if ( i === 2 ) { - return next( new Error( 'boop' ) ); - } - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 3, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'the function does not guarantee asynchronous execution', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - k = 1; - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - next(); - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( k, 0, 'releases the zalgo' ); - t.end(); - } -}); From b2b8b696de5a6f902d565b7579c8c524035c5939 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 27 Jul 2024 00:47:41 +0000 Subject: [PATCH 115/143] 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 1dafc2a..c1bab44 100644 --- a/lib/main.js +++ b/lib/main.js @@ -21,7 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -62,13 +62,13 @@ function whileAsync( predicate, fcn, done, thisArg ) { var args; var idx; if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '1Rr3c', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '1Rr2H', fcn ) ); } if ( !isFunction( done ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', done ) ); + throw new TypeError( format( '1Rr3N', done ) ); } args = []; idx = 0; diff --git a/package.json b/package.json index e14e2bb..9fd92e6 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ }, "dependencies": { "@stdlib/assert-is-function": "^0.2.1", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { From 139beeb8e39c7101ac5dd96f48d304775399bf8e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 27 Jul 2024 01:13:38 +0000 Subject: [PATCH 116/143] Remove files --- index.d.ts | 127 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4974 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 163e8ba..0000000 --- a/index.d.ts +++ /dev/null @@ -1,127 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Callback function. -*/ -type Nullary = () => void; - -/** -* Callback function. -* -* @param error - encountered error or null -*/ -type Unary = ( error: Error | null ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Binary = ( error: Error | null, bool: boolean ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Callback = Nullary | Unary | Binary; - -/** -* Callback invoked upon completion. -*/ -type DoneNullary = () => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -*/ -type DoneUnary = ( error: Error | null ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneBinary = ( error: Error | null, ...args: Array ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneCallback = DoneNullary | DoneUnary | DoneBinary; - -/** -* Checks whether an element in a collection passes a test. -* -* @param i - iteration number (starting from one) -* @param clbk - a callback indicating whether to invoke `fcn` -*/ -type Predicate = ( i: number, clbk: Callback ) => void; - -/** -* Invoked function. -* -* @param i - iteration number (starting from zero) -* @param next - a callback which must be invoked before proceeding to the next iteration -*/ -type Fcn = ( i: number, next: Function ) => void; - -/** -* Invokes a function while a test condition is true. -* -* @param predicate - function which indicates whether to continue invoking a function -* @param fcn - function to invoke -* @param done - callback to invoke upon completion -* @param thisArg - execution context for the invoked function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -declare function whileAsync( predicate: Predicate, fcn: Fcn, done: DoneCallback, thisArg?: any ): void; - - -// EXPORTS // - -export = whileAsync; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 5136fa0..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-function@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function n(n,e,o,i){var s,l;if(!r(n))throw new TypeError(t("1Rr3c",n));if(!r(e))throw new TypeError(t("1Rr2H",e));if(!r(o))throw new TypeError(t("1Rr3N",o));function f(r,t){return r?o(r):t?e.call(i,l,h):(s.length&&s.unshift(null),void o.apply(null,s))}function h(r){var t;if(r)return o(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;8LA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index a6615ea..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 597b1e9905ffa67b8e6b17ff3e29295494bcac6e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 27 Jul 2024 01:13:51 +0000 Subject: [PATCH 117/143] 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 | 205 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 105 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 72 - docs/types/test.ts | 83 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 57 - lib/main.js | 128 - package.json | 57 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 328 -- 42 files changed, 4867 insertions(+), 4387 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 (100%) 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 0f8dec8..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/async/while) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 9633c26..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/async/while) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 0bdf3fd..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: '8 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' - # 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 + + ```
@@ -292,7 +283,7 @@ whileAsync( predicate, fcn, done ); ## 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]. @@ -357,13 +348,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until +[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until/tree/esm -[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while +[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while/tree/esm -[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until +[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until/tree/esm -[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while +[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while/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 7c83acf..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var whileAsync = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); - -bench( pkg+'::sync_predicate', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2c3ed87..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/async/while" -%% click B href "https://github.com/stdlib-js/utils-async-while/tree/main" -%% click C href "https://github.com/stdlib-js/utils-async-while/tree/production" -%% click D href "https://github.com/stdlib-js/utils-async-while/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-async-while/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-async-while/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/async/while -[production-url]: https://github.com/stdlib-js/utils-async-while/tree/production -[deno-url]: https://github.com/stdlib-js/utils-async-while/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-async-while/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-async-while/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-async-while/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-async-while/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-async-while/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 efdafdf..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import whileAsync from '../docs/types/index'; -export = whileAsync; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 159efee..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var v=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var m=v(function(p,g){ -var s=require('@stdlib/assert-is-function/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist');function c(t,r,e,o){var u,i;if(!s(t))throw new TypeError(l('1Rr3c',t));if(!s(r))throw new TypeError(l('1Rr2H',r));if(!s(e))throw new TypeError(l('1Rr3N',e));u=[],i=0,t(i,f);function f(a,n){if(a)return e(a);if(n)return r.call(o,i,h);u.length&&u.unshift(null),e.apply(null,u)}function h(a){var n;if(a)return e(a);if(i+=1,arguments.length>1)for(u=new Array(arguments.length-1),n=1;n 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = whileAsync;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Invoke a function while a test condition is true.\n*\n* @module @stdlib/utils-async-while\n*\n* @example\n* var whileAsync = require( '@stdlib/utils-async-while' );\n*\n* function predicate( i, clbk ) {\n* clbk( null, i < 5 );\n* }\n*\n* function fcn( i, next ) {\n* setTimeout( onTimeout, i );\n* function onTimeout() {\n* console.log( 'beep: %d', i );\n* next();\n* }\n* }\n*\n* function done( error ) {\n* if ( error ) {\n* throw error;\n* }\n* }\n*\n* whileAsync( predicate, fcn, done );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAS,QAAS,uBAAwB,EAqC9C,SAASC,EAAYC,EAAWC,EAAKC,EAAMC,EAAU,CACpD,IAAIC,EACAC,EACJ,GAAK,CAACR,EAAYG,CAAU,EAC3B,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAU,CAAE,EAE/G,GAAK,CAACH,EAAYI,CAAI,EACrB,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAI,CAAE,EAE1G,GAAK,CAACJ,EAAYK,CAAK,EACtB,MAAM,IAAI,UAAWJ,EAAQ,oEAAqEI,CAAK,CAAE,EAE1GE,EAAO,CAAC,EACRC,EAAM,EACNL,EAAWK,EAAKC,CAAY,EAU5B,SAASA,EAAaC,EAAOC,EAAS,CACrC,GAAKD,EACJ,OAAOL,EAAMK,CAAM,EAEpB,GAAKC,EACJ,OAAOP,EAAI,KAAME,EAASE,EAAKI,CAAK,EAEhCL,EAAK,QACTA,EAAK,QAAS,IAAK,EAEpBF,EAAK,MAAO,KAAME,CAAK,CACxB,CAUA,SAASK,EAAMF,EAAQ,CACtB,IAAIG,EACJ,GAAKH,EACJ,OAAOL,EAAMK,CAAM,EAKpB,GAHAF,GAAO,EAGF,UAAU,OAAS,EAEvB,IADAD,EAAO,IAAI,MAAO,UAAU,OAAO,CAAE,EAC/BM,EAAI,EAAGA,EAAI,UAAU,OAAQA,IAClCN,EAAMM,EAAE,CAAE,EAAI,UAAWA,CAAE,EAI7BV,EAAWK,EAAKC,CAAY,CAC7B,CACD,CAKAV,EAAO,QAAUG,IC5EjB,IAAIY,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "format", "whileAsync", "predicate", "fcn", "done", "thisArg", "args", "idx", "onPredicate", "error", "result", "next", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index d7ca8c9..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,72 +0,0 @@ - -{{alias}}( predicate, fcn, done[, thisArg] ) - Invokes a function while a test condition is true. - - The predicate function is provided two arguments: - - - `i`: iteration number (starting from zero) - - `clbk`: a callback indicating whether to invoke `fcn` - - The `clbk` function accepts two arguments: - - - `error`: error argument - - `bool`: test result - - If the test result is truthy, the function invokes `fcn`; otherwise, the - function invokes the `done` callback. - - The function to invoke is provided two arguments: - - - `i`: iteration number (starting from zero) - - `next`: a callback which must be invoked before proceeding to the next - iteration - - The first argument of the `next` callback is an `error` argument. If `fcn` - calls the `next` callback with a truthy `error` argument, the function - suspends execution and immediately calls the `done` callback for subsequent - `error` handling. - - The `done` callback is invoked with an `error` argument and any arguments - passed to the final `next` callback. - - Execution is *not* guaranteed to be asynchronous. To guarantee asynchrony, - wrap the `done` callback in a function which either executes at the end of - the current stack (e.g., `nextTick`) or during a subsequent turn of the - event loop (e.g., `setImmediate`, `setTimeout`). - - Parameters - ---------- - predicate: Function - The predicate function which indicates whether to continue invoking a - function. - - fcn: Function - The function to invoke. - - done: Function - Callback to invoke upon completion. - - thisArg: any (optional) - Execution context for the invoked function. - - Examples - -------- - > function predicate( i, clbk ) { clbk( null, i < 5 ); }; - > function fcn( i, next ) { - ... setTimeout( onTimeout, i ); - ... function onTimeout() { - ... next( null, 'boop'+i ); - ... } - ... }; - > function done( error, result ) { - ... if ( error ) { - ... throw error; - ... } - ... console.log( result ); - ... }; - > {{alias}}( predicate, fcn, done ) - boop: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4a543d9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,83 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 whileAsync = require( './index' ); - -const fcn = ( i: number, next: Function ): void => { - if ( i === void 0 ) { - throw new Error( '`i` is missing.' ); - } - next(); -}; - -const predicate = ( i: number, clbk: Function ): void => { - clbk( null, i < 5 ); -}; - -const done = ( error: Error | null ): void => { - if ( error ) { - throw error; - } -}; - - -// TESTS // - -// The function returns void... -{ - whileAsync( predicate, fcn, done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a predicate function... -{ - whileAsync( 2, fcn, done ); // $ExpectError - whileAsync( false, fcn, done ); // $ExpectError - whileAsync( true, fcn, done ); // $ExpectError - whileAsync( 'abc', fcn, done ); // $ExpectError - whileAsync( {}, fcn, done ); // $ExpectError - whileAsync( [], fcn, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function having a supported signature... -{ - whileAsync( predicate, 2, done ); // $ExpectError - whileAsync( predicate, false, done ); // $ExpectError - whileAsync( predicate, true, done ); // $ExpectError - whileAsync( predicate, 'abc', done ); // $ExpectError - whileAsync( predicate, {}, done ); // $ExpectError - whileAsync( predicate, [], done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a done callback argument which is not a function having a supported signature... -{ - whileAsync( predicate, fcn, 2 ); // $ExpectError - whileAsync( predicate, fcn, false ); // $ExpectError - whileAsync( predicate, fcn, true ); // $ExpectError - whileAsync( predicate, fcn, 'abc' ); // $ExpectError - whileAsync( predicate, fcn, {} ); // $ExpectError - whileAsync( predicate, fcn, [] ); // $ExpectError - whileAsync( predicate, fcn, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - whileAsync(); // $ExpectError - whileAsync( predicate ); // $ExpectError - whileAsync( predicate, fcn ); // $ExpectError - whileAsync( predicate, fcn, done, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a6af668..0000000 --- a/examples/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var repeatString = require( '@stdlib/string-repeat' ); -var whileAsync = require( './../lib' ); - -function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } -} - -function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, repeatString( 'beep', i+1 ) ); - } -} - -function done( error, result ) { - if ( error ) { - throw error; - } - console.log( result ); -} - -whileAsync( predicate, fcn, done ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..8cb0742 --- /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-function@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function n(n,e,o,i){var s,l;if(!r(n))throw new TypeError(t("1Rr3c",n));if(!r(e))throw new TypeError(t("1Rr2H",e));if(!r(o))throw new TypeError(t("1Rr3N",o));function f(r,t){return r?o(r):t?e.call(i,l,h):(s.length&&s.unshift(null),void o.apply(null,s))}function h(r){var t;if(r)return o(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;8LA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a13bd4..0000000 --- a/lib/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Invoke a function while a test condition is true. -* -* @module @stdlib/utils-async-while -* -* @example -* var whileAsync = require( '@stdlib/utils-async-while' ); -* -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c1bab44..0000000 --- a/lib/main.js +++ /dev/null @@ -1,128 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Invokes a function while a test condition is true. -* -* @param {Function} predicate - function which indicates whether to continue invoking a function -* @param {Function} fcn - function to invoke -* @param {Callback} done - callback to invoke upon completion -* @param {*} [thisArg] - execution context for the invoked function -* @throws {TypeError} first argument must be a function -* @throws {TypeError} second argument must be a function -* @throws {TypeError} third argument must be a function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -function whileAsync( predicate, fcn, done, thisArg ) { - var args; - var idx; - if ( !isFunction( predicate ) ) { - throw new TypeError( format( '1Rr3c', predicate ) ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '1Rr2H', fcn ) ); - } - if ( !isFunction( done ) ) { - throw new TypeError( format( '1Rr3N', done ) ); - } - args = []; - idx = 0; - predicate( idx, onPredicate ); - - /** - * Callback invoked upon a predicate result. - * - * @private - * @param {(Error|null)} error - error object - * @param {boolean} result - predicate result - * @returns {void} - */ - function onPredicate( error, result ) { - if ( error ) { - return done( error ); - } - if ( result ) { - return fcn.call( thisArg, idx, next ); - } - if ( args.length ) { - args.unshift( null ); // error argument - } - done.apply( null, args ); - } - - /** - * Callback invoked upon completion of a provided function. - * - * @private - * @param {(Error|null)} error - error object - * @param {...*} results - function results - * @returns {void} - */ - function next( error ) { - var i; - if ( error ) { - return done( error ); - } - idx += 1; - - // Cache the most recent results... - if ( arguments.length > 1 ) { - args = new Array( arguments.length-1 ); - for ( i = 1; i < arguments.length; i++ ) { - args[ i-1 ] = arguments[ i ]; - } - } - // Run the test condition: - predicate( idx, onPredicate ); - } -} - - -// EXPORTS // - -module.exports = whileAsync; diff --git a/package.json b/package.json index 9fd92e6..e1990aa 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Invoke a function while a test condition is true.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/math-base-assert-is-nan": "^0.2.1", - "@stdlib/random-base-randu": "^0.2.1", - "@stdlib/string-repeat": "^0.2.1", - "@stdlib/utils-noop": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=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..7f76d6e --- /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 78d0688..0000000 --- a/test/test.js +++ /dev/null @@ -1,328 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 whileAsync = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof whileAsync, 'function', 'main export is a function' ); - t.end(); -}); - -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() { - whileAsync( value, noop, 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() { - whileAsync( noop, value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a callback 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() { - whileAsync( noop, noop, value ); - }; - } -}); - -tape( 'while a test condition is true, the function invokes a provided function', function test( t ) { - var indices1 = [ 0, 1, 2, 3, 4, 5 ]; - var indices2 = [ 0, 1, 2, 3, 4 ]; - var j = -1; - var k = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices1[ j ], 'provides expected value' ); - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - k += 1; - t.strictEqual( i, indices2[ k ], 'provides expected value' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'while a test condition is true, the function invokes a provided function (always false)', function test( t ) { - var indices = [ 0 ]; - var j = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices[ j ], 'provides expected value' ); - clbk( null, false ); - } - - function fcn( i, next ) { - t.fail( 'should never be invoked' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx = { - 'count': 0 - }; - - whileAsync( predicate, fcn, done, ctx ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - this.count += 1; // eslint-disable-line no-invalid-this - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( ctx.count, 5, 'updates context' ); - t.end(); - } -}); - -tape( 'the function provides any results to a `done` callback', function test( t ) { - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, 'beep'+i, 'boop'+i, 'woot'+i ); - } - } - - function done( error, str1, str2, str3 ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( str1, 'beep4', 'returns expected value' ); - t.strictEqual( str2, 'boop4', 'returns expected value' ); - t.strictEqual( str3, 'woot4', 'returns expected value' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the predicate function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - if ( i === 1 ) { - return clbk( new Error( 'beep' ) ); - } - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 2, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the provided function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - if ( i === 2 ) { - return next( new Error( 'boop' ) ); - } - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 3, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'the function does not guarantee asynchronous execution', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - k = 1; - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - next(); - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( k, 0, 'releases the zalgo' ); - t.end(); - } -}); From 92ad71feea7a6c0e03e8254d9c61b77fe1893b9e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 27 Jul 2024 01:25:05 +0000 Subject: [PATCH 118/143] 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 a17bc22..7bf9944 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import whileAsync from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-async-while@esm/index.mjs'; +import whileAsync from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-async-while@v0.2.2-esm/index.mjs'; ``` #### whileAsync( predicate, fcn, done\[, thisArg ] ) @@ -215,7 +215,7 @@ function done( error ) { - - - - From 0e9b0a7a343cae86e11ad2a94d4b3256a885076d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 02:46:49 +0000 Subject: [PATCH 122/143] 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 | 168 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 105 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 72 - docs/types/test.ts | 83 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 57 - lib/main.js | 128 - package.json | 57 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 328 -- 43 files changed, 4867 insertions(+), 4353 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 (100%) 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 2d2409e..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-08-01T01:10:58.647Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 0f8dec8..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/async/while) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 9633c26..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/async/while) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 0bdf3fd..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: '8 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' - # 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 + + ```
@@ -292,7 +283,7 @@ whileAsync( predicate, fcn, done ); ## 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]. @@ -357,13 +348,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until +[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until/tree/esm -[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while +[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while/tree/esm -[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until +[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until/tree/esm -[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while +[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while/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 7c83acf..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var whileAsync = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); - -bench( pkg+'::sync_predicate', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2c3ed87..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/async/while" -%% click B href "https://github.com/stdlib-js/utils-async-while/tree/main" -%% click C href "https://github.com/stdlib-js/utils-async-while/tree/production" -%% click D href "https://github.com/stdlib-js/utils-async-while/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-async-while/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-async-while/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/async/while -[production-url]: https://github.com/stdlib-js/utils-async-while/tree/production -[deno-url]: https://github.com/stdlib-js/utils-async-while/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-async-while/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-async-while/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-async-while/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-async-while/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-async-while/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 efdafdf..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import whileAsync from '../docs/types/index'; -export = whileAsync; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 159efee..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var v=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var m=v(function(p,g){ -var s=require('@stdlib/assert-is-function/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist');function c(t,r,e,o){var u,i;if(!s(t))throw new TypeError(l('1Rr3c',t));if(!s(r))throw new TypeError(l('1Rr2H',r));if(!s(e))throw new TypeError(l('1Rr3N',e));u=[],i=0,t(i,f);function f(a,n){if(a)return e(a);if(n)return r.call(o,i,h);u.length&&u.unshift(null),e.apply(null,u)}function h(a){var n;if(a)return e(a);if(i+=1,arguments.length>1)for(u=new Array(arguments.length-1),n=1;n 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = whileAsync;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Invoke a function while a test condition is true.\n*\n* @module @stdlib/utils-async-while\n*\n* @example\n* var whileAsync = require( '@stdlib/utils-async-while' );\n*\n* function predicate( i, clbk ) {\n* clbk( null, i < 5 );\n* }\n*\n* function fcn( i, next ) {\n* setTimeout( onTimeout, i );\n* function onTimeout() {\n* console.log( 'beep: %d', i );\n* next();\n* }\n* }\n*\n* function done( error ) {\n* if ( error ) {\n* throw error;\n* }\n* }\n*\n* whileAsync( predicate, fcn, done );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAS,QAAS,uBAAwB,EAqC9C,SAASC,EAAYC,EAAWC,EAAKC,EAAMC,EAAU,CACpD,IAAIC,EACAC,EACJ,GAAK,CAACR,EAAYG,CAAU,EAC3B,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAU,CAAE,EAE/G,GAAK,CAACH,EAAYI,CAAI,EACrB,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAI,CAAE,EAE1G,GAAK,CAACJ,EAAYK,CAAK,EACtB,MAAM,IAAI,UAAWJ,EAAQ,oEAAqEI,CAAK,CAAE,EAE1GE,EAAO,CAAC,EACRC,EAAM,EACNL,EAAWK,EAAKC,CAAY,EAU5B,SAASA,EAAaC,EAAOC,EAAS,CACrC,GAAKD,EACJ,OAAOL,EAAMK,CAAM,EAEpB,GAAKC,EACJ,OAAOP,EAAI,KAAME,EAASE,EAAKI,CAAK,EAEhCL,EAAK,QACTA,EAAK,QAAS,IAAK,EAEpBF,EAAK,MAAO,KAAME,CAAK,CACxB,CAUA,SAASK,EAAMF,EAAQ,CACtB,IAAIG,EACJ,GAAKH,EACJ,OAAOL,EAAMK,CAAM,EAKpB,GAHAF,GAAO,EAGF,UAAU,OAAS,EAEvB,IADAD,EAAO,IAAI,MAAO,UAAU,OAAO,CAAE,EAC/BM,EAAI,EAAGA,EAAI,UAAU,OAAQA,IAClCN,EAAMM,EAAE,CAAE,EAAI,UAAWA,CAAE,EAI7BV,EAAWK,EAAKC,CAAY,CAC7B,CACD,CAKAV,EAAO,QAAUG,IC5EjB,IAAIY,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "format", "whileAsync", "predicate", "fcn", "done", "thisArg", "args", "idx", "onPredicate", "error", "result", "next", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index d7ca8c9..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,72 +0,0 @@ - -{{alias}}( predicate, fcn, done[, thisArg] ) - Invokes a function while a test condition is true. - - The predicate function is provided two arguments: - - - `i`: iteration number (starting from zero) - - `clbk`: a callback indicating whether to invoke `fcn` - - The `clbk` function accepts two arguments: - - - `error`: error argument - - `bool`: test result - - If the test result is truthy, the function invokes `fcn`; otherwise, the - function invokes the `done` callback. - - The function to invoke is provided two arguments: - - - `i`: iteration number (starting from zero) - - `next`: a callback which must be invoked before proceeding to the next - iteration - - The first argument of the `next` callback is an `error` argument. If `fcn` - calls the `next` callback with a truthy `error` argument, the function - suspends execution and immediately calls the `done` callback for subsequent - `error` handling. - - The `done` callback is invoked with an `error` argument and any arguments - passed to the final `next` callback. - - Execution is *not* guaranteed to be asynchronous. To guarantee asynchrony, - wrap the `done` callback in a function which either executes at the end of - the current stack (e.g., `nextTick`) or during a subsequent turn of the - event loop (e.g., `setImmediate`, `setTimeout`). - - Parameters - ---------- - predicate: Function - The predicate function which indicates whether to continue invoking a - function. - - fcn: Function - The function to invoke. - - done: Function - Callback to invoke upon completion. - - thisArg: any (optional) - Execution context for the invoked function. - - Examples - -------- - > function predicate( i, clbk ) { clbk( null, i < 5 ); }; - > function fcn( i, next ) { - ... setTimeout( onTimeout, i ); - ... function onTimeout() { - ... next( null, 'boop'+i ); - ... } - ... }; - > function done( error, result ) { - ... if ( error ) { - ... throw error; - ... } - ... console.log( result ); - ... }; - > {{alias}}( predicate, fcn, done ) - boop: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4a543d9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,83 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 whileAsync = require( './index' ); - -const fcn = ( i: number, next: Function ): void => { - if ( i === void 0 ) { - throw new Error( '`i` is missing.' ); - } - next(); -}; - -const predicate = ( i: number, clbk: Function ): void => { - clbk( null, i < 5 ); -}; - -const done = ( error: Error | null ): void => { - if ( error ) { - throw error; - } -}; - - -// TESTS // - -// The function returns void... -{ - whileAsync( predicate, fcn, done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a predicate function... -{ - whileAsync( 2, fcn, done ); // $ExpectError - whileAsync( false, fcn, done ); // $ExpectError - whileAsync( true, fcn, done ); // $ExpectError - whileAsync( 'abc', fcn, done ); // $ExpectError - whileAsync( {}, fcn, done ); // $ExpectError - whileAsync( [], fcn, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function having a supported signature... -{ - whileAsync( predicate, 2, done ); // $ExpectError - whileAsync( predicate, false, done ); // $ExpectError - whileAsync( predicate, true, done ); // $ExpectError - whileAsync( predicate, 'abc', done ); // $ExpectError - whileAsync( predicate, {}, done ); // $ExpectError - whileAsync( predicate, [], done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a done callback argument which is not a function having a supported signature... -{ - whileAsync( predicate, fcn, 2 ); // $ExpectError - whileAsync( predicate, fcn, false ); // $ExpectError - whileAsync( predicate, fcn, true ); // $ExpectError - whileAsync( predicate, fcn, 'abc' ); // $ExpectError - whileAsync( predicate, fcn, {} ); // $ExpectError - whileAsync( predicate, fcn, [] ); // $ExpectError - whileAsync( predicate, fcn, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - whileAsync(); // $ExpectError - whileAsync( predicate ); // $ExpectError - whileAsync( predicate, fcn ); // $ExpectError - whileAsync( predicate, fcn, done, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a6af668..0000000 --- a/examples/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var repeatString = require( '@stdlib/string-repeat' ); -var whileAsync = require( './../lib' ); - -function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } -} - -function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, repeatString( 'beep', i+1 ) ); - } -} - -function done( error, result ) { - if ( error ) { - throw error; - } - console.log( result ); -} - -whileAsync( predicate, fcn, done ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..6f152ad --- /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-function@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function n(n,e,o,i){var s,l;if(!r(n))throw new TypeError(t("1Rr3c",n));if(!r(e))throw new TypeError(t("1Rr2H",e));if(!r(o))throw new TypeError(t("1Rr3N",o));function f(r,t){return r?o(r):t?e.call(i,l,h):(s.length&&s.unshift(null),void o.apply(null,s))}function h(r){var t;if(r)return o(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;8LA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a13bd4..0000000 --- a/lib/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Invoke a function while a test condition is true. -* -* @module @stdlib/utils-async-while -* -* @example -* var whileAsync = require( '@stdlib/utils-async-while' ); -* -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c1bab44..0000000 --- a/lib/main.js +++ /dev/null @@ -1,128 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Invokes a function while a test condition is true. -* -* @param {Function} predicate - function which indicates whether to continue invoking a function -* @param {Function} fcn - function to invoke -* @param {Callback} done - callback to invoke upon completion -* @param {*} [thisArg] - execution context for the invoked function -* @throws {TypeError} first argument must be a function -* @throws {TypeError} second argument must be a function -* @throws {TypeError} third argument must be a function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -function whileAsync( predicate, fcn, done, thisArg ) { - var args; - var idx; - if ( !isFunction( predicate ) ) { - throw new TypeError( format( '1Rr3c', predicate ) ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '1Rr2H', fcn ) ); - } - if ( !isFunction( done ) ) { - throw new TypeError( format( '1Rr3N', done ) ); - } - args = []; - idx = 0; - predicate( idx, onPredicate ); - - /** - * Callback invoked upon a predicate result. - * - * @private - * @param {(Error|null)} error - error object - * @param {boolean} result - predicate result - * @returns {void} - */ - function onPredicate( error, result ) { - if ( error ) { - return done( error ); - } - if ( result ) { - return fcn.call( thisArg, idx, next ); - } - if ( args.length ) { - args.unshift( null ); // error argument - } - done.apply( null, args ); - } - - /** - * Callback invoked upon completion of a provided function. - * - * @private - * @param {(Error|null)} error - error object - * @param {...*} results - function results - * @returns {void} - */ - function next( error ) { - var i; - if ( error ) { - return done( error ); - } - idx += 1; - - // Cache the most recent results... - if ( arguments.length > 1 ) { - args = new Array( arguments.length-1 ); - for ( i = 1; i < arguments.length; i++ ) { - args[ i-1 ] = arguments[ i ]; - } - } - // Run the test condition: - predicate( idx, onPredicate ); - } -} - - -// EXPORTS // - -module.exports = whileAsync; diff --git a/package.json b/package.json index a94b816..e1990aa 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Invoke a function while a test condition is true.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/math-base-assert-is-nan": "^0.2.2", - "@stdlib/random-base-randu": "^0.2.1", - "@stdlib/string-repeat": "^0.2.2", - "@stdlib/utils-noop": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..7a166a5 --- /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 78d0688..0000000 --- a/test/test.js +++ /dev/null @@ -1,328 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 whileAsync = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof whileAsync, 'function', 'main export is a function' ); - t.end(); -}); - -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() { - whileAsync( value, noop, 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() { - whileAsync( noop, value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a callback 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() { - whileAsync( noop, noop, value ); - }; - } -}); - -tape( 'while a test condition is true, the function invokes a provided function', function test( t ) { - var indices1 = [ 0, 1, 2, 3, 4, 5 ]; - var indices2 = [ 0, 1, 2, 3, 4 ]; - var j = -1; - var k = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices1[ j ], 'provides expected value' ); - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - k += 1; - t.strictEqual( i, indices2[ k ], 'provides expected value' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'while a test condition is true, the function invokes a provided function (always false)', function test( t ) { - var indices = [ 0 ]; - var j = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices[ j ], 'provides expected value' ); - clbk( null, false ); - } - - function fcn( i, next ) { - t.fail( 'should never be invoked' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx = { - 'count': 0 - }; - - whileAsync( predicate, fcn, done, ctx ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - this.count += 1; // eslint-disable-line no-invalid-this - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( ctx.count, 5, 'updates context' ); - t.end(); - } -}); - -tape( 'the function provides any results to a `done` callback', function test( t ) { - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, 'beep'+i, 'boop'+i, 'woot'+i ); - } - } - - function done( error, str1, str2, str3 ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( str1, 'beep4', 'returns expected value' ); - t.strictEqual( str2, 'boop4', 'returns expected value' ); - t.strictEqual( str3, 'woot4', 'returns expected value' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the predicate function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - if ( i === 1 ) { - return clbk( new Error( 'beep' ) ); - } - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 2, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the provided function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - if ( i === 2 ) { - return next( new Error( 'boop' ) ); - } - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 3, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'the function does not guarantee asynchronous execution', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - k = 1; - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - next(); - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( k, 0, 'releases the zalgo' ); - t.end(); - } -}); From 81cf0700a5c214ffbd6354c1da2a8e0ff2b2fc40 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Aug 2024 16:08:04 +0000 Subject: [PATCH 123/143] 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 1dafc2a..c1bab44 100644 --- a/lib/main.js +++ b/lib/main.js @@ -21,7 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -62,13 +62,13 @@ function whileAsync( predicate, fcn, done, thisArg ) { var args; var idx; if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '1Rr3c', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '1Rr2H', fcn ) ); } if ( !isFunction( done ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', done ) ); + throw new TypeError( format( '1Rr3N', done ) ); } args = []; idx = 0; diff --git a/package.json b/package.json index 77fbf5f..a94b816 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ }, "dependencies": { "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { From 7604e23a50a136749f9f14fbd7a62a36ae6b04a1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Aug 2024 16:51:49 +0000 Subject: [PATCH 124/143] Remove files --- index.d.ts | 127 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4974 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 163e8ba..0000000 --- a/index.d.ts +++ /dev/null @@ -1,127 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Callback function. -*/ -type Nullary = () => void; - -/** -* Callback function. -* -* @param error - encountered error or null -*/ -type Unary = ( error: Error | null ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Binary = ( error: Error | null, bool: boolean ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Callback = Nullary | Unary | Binary; - -/** -* Callback invoked upon completion. -*/ -type DoneNullary = () => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -*/ -type DoneUnary = ( error: Error | null ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneBinary = ( error: Error | null, ...args: Array ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneCallback = DoneNullary | DoneUnary | DoneBinary; - -/** -* Checks whether an element in a collection passes a test. -* -* @param i - iteration number (starting from one) -* @param clbk - a callback indicating whether to invoke `fcn` -*/ -type Predicate = ( i: number, clbk: Callback ) => void; - -/** -* Invoked function. -* -* @param i - iteration number (starting from zero) -* @param next - a callback which must be invoked before proceeding to the next iteration -*/ -type Fcn = ( i: number, next: Function ) => void; - -/** -* Invokes a function while a test condition is true. -* -* @param predicate - function which indicates whether to continue invoking a function -* @param fcn - function to invoke -* @param done - callback to invoke upon completion -* @param thisArg - execution context for the invoked function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -declare function whileAsync( predicate: Predicate, fcn: Fcn, done: DoneCallback, thisArg?: any ): void; - - -// EXPORTS // - -export = whileAsync; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 6f152ad..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-function@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function n(n,e,o,i){var s,l;if(!r(n))throw new TypeError(t("1Rr3c",n));if(!r(e))throw new TypeError(t("1Rr2H",e));if(!r(o))throw new TypeError(t("1Rr3N",o));function f(r,t){return r?o(r):t?e.call(i,l,h):(s.length&&s.unshift(null),void o.apply(null,s))}function h(r){var t;if(r)return o(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;8LA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 7a166a5..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 251e6501cf879a0e1e415b54a528c7f624036263 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Aug 2024 16:52:05 +0000 Subject: [PATCH 125/143] 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 | 205 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 105 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 72 - docs/types/test.ts | 83 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 57 - lib/main.js | 128 - package.json | 57 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 328 -- 43 files changed, 4867 insertions(+), 4390 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 (100%) 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 2ce6471..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-08-03T15:54:11.852Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 0f8dec8..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/async/while) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 9633c26..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/async/while) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 0bdf3fd..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: '8 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' - # 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 + + ```
@@ -292,7 +283,7 @@ whileAsync( predicate, fcn, done ); ## 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]. @@ -357,13 +348,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until +[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until/tree/esm -[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while +[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while/tree/esm -[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until +[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until/tree/esm -[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while +[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while/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 7c83acf..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var whileAsync = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); - -bench( pkg+'::sync_predicate', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2c3ed87..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/async/while" -%% click B href "https://github.com/stdlib-js/utils-async-while/tree/main" -%% click C href "https://github.com/stdlib-js/utils-async-while/tree/production" -%% click D href "https://github.com/stdlib-js/utils-async-while/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-async-while/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-async-while/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/async/while -[production-url]: https://github.com/stdlib-js/utils-async-while/tree/production -[deno-url]: https://github.com/stdlib-js/utils-async-while/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-async-while/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-async-while/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-async-while/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-async-while/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-async-while/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 efdafdf..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import whileAsync from '../docs/types/index'; -export = whileAsync; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 159efee..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var v=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var m=v(function(p,g){ -var s=require('@stdlib/assert-is-function/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist');function c(t,r,e,o){var u,i;if(!s(t))throw new TypeError(l('1Rr3c',t));if(!s(r))throw new TypeError(l('1Rr2H',r));if(!s(e))throw new TypeError(l('1Rr3N',e));u=[],i=0,t(i,f);function f(a,n){if(a)return e(a);if(n)return r.call(o,i,h);u.length&&u.unshift(null),e.apply(null,u)}function h(a){var n;if(a)return e(a);if(i+=1,arguments.length>1)for(u=new Array(arguments.length-1),n=1;n 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = whileAsync;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Invoke a function while a test condition is true.\n*\n* @module @stdlib/utils-async-while\n*\n* @example\n* var whileAsync = require( '@stdlib/utils-async-while' );\n*\n* function predicate( i, clbk ) {\n* clbk( null, i < 5 );\n* }\n*\n* function fcn( i, next ) {\n* setTimeout( onTimeout, i );\n* function onTimeout() {\n* console.log( 'beep: %d', i );\n* next();\n* }\n* }\n*\n* function done( error ) {\n* if ( error ) {\n* throw error;\n* }\n* }\n*\n* whileAsync( predicate, fcn, done );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAS,QAAS,uBAAwB,EAqC9C,SAASC,EAAYC,EAAWC,EAAKC,EAAMC,EAAU,CACpD,IAAIC,EACAC,EACJ,GAAK,CAACR,EAAYG,CAAU,EAC3B,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAU,CAAE,EAE/G,GAAK,CAACH,EAAYI,CAAI,EACrB,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAI,CAAE,EAE1G,GAAK,CAACJ,EAAYK,CAAK,EACtB,MAAM,IAAI,UAAWJ,EAAQ,oEAAqEI,CAAK,CAAE,EAE1GE,EAAO,CAAC,EACRC,EAAM,EACNL,EAAWK,EAAKC,CAAY,EAU5B,SAASA,EAAaC,EAAOC,EAAS,CACrC,GAAKD,EACJ,OAAOL,EAAMK,CAAM,EAEpB,GAAKC,EACJ,OAAOP,EAAI,KAAME,EAASE,EAAKI,CAAK,EAEhCL,EAAK,QACTA,EAAK,QAAS,IAAK,EAEpBF,EAAK,MAAO,KAAME,CAAK,CACxB,CAUA,SAASK,EAAMF,EAAQ,CACtB,IAAIG,EACJ,GAAKH,EACJ,OAAOL,EAAMK,CAAM,EAKpB,GAHAF,GAAO,EAGF,UAAU,OAAS,EAEvB,IADAD,EAAO,IAAI,MAAO,UAAU,OAAO,CAAE,EAC/BM,EAAI,EAAGA,EAAI,UAAU,OAAQA,IAClCN,EAAMM,EAAE,CAAE,EAAI,UAAWA,CAAE,EAI7BV,EAAWK,EAAKC,CAAY,CAC7B,CACD,CAKAV,EAAO,QAAUG,IC5EjB,IAAIY,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "format", "whileAsync", "predicate", "fcn", "done", "thisArg", "args", "idx", "onPredicate", "error", "result", "next", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index d7ca8c9..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,72 +0,0 @@ - -{{alias}}( predicate, fcn, done[, thisArg] ) - Invokes a function while a test condition is true. - - The predicate function is provided two arguments: - - - `i`: iteration number (starting from zero) - - `clbk`: a callback indicating whether to invoke `fcn` - - The `clbk` function accepts two arguments: - - - `error`: error argument - - `bool`: test result - - If the test result is truthy, the function invokes `fcn`; otherwise, the - function invokes the `done` callback. - - The function to invoke is provided two arguments: - - - `i`: iteration number (starting from zero) - - `next`: a callback which must be invoked before proceeding to the next - iteration - - The first argument of the `next` callback is an `error` argument. If `fcn` - calls the `next` callback with a truthy `error` argument, the function - suspends execution and immediately calls the `done` callback for subsequent - `error` handling. - - The `done` callback is invoked with an `error` argument and any arguments - passed to the final `next` callback. - - Execution is *not* guaranteed to be asynchronous. To guarantee asynchrony, - wrap the `done` callback in a function which either executes at the end of - the current stack (e.g., `nextTick`) or during a subsequent turn of the - event loop (e.g., `setImmediate`, `setTimeout`). - - Parameters - ---------- - predicate: Function - The predicate function which indicates whether to continue invoking a - function. - - fcn: Function - The function to invoke. - - done: Function - Callback to invoke upon completion. - - thisArg: any (optional) - Execution context for the invoked function. - - Examples - -------- - > function predicate( i, clbk ) { clbk( null, i < 5 ); }; - > function fcn( i, next ) { - ... setTimeout( onTimeout, i ); - ... function onTimeout() { - ... next( null, 'boop'+i ); - ... } - ... }; - > function done( error, result ) { - ... if ( error ) { - ... throw error; - ... } - ... console.log( result ); - ... }; - > {{alias}}( predicate, fcn, done ) - boop: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4a543d9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,83 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 whileAsync = require( './index' ); - -const fcn = ( i: number, next: Function ): void => { - if ( i === void 0 ) { - throw new Error( '`i` is missing.' ); - } - next(); -}; - -const predicate = ( i: number, clbk: Function ): void => { - clbk( null, i < 5 ); -}; - -const done = ( error: Error | null ): void => { - if ( error ) { - throw error; - } -}; - - -// TESTS // - -// The function returns void... -{ - whileAsync( predicate, fcn, done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a predicate function... -{ - whileAsync( 2, fcn, done ); // $ExpectError - whileAsync( false, fcn, done ); // $ExpectError - whileAsync( true, fcn, done ); // $ExpectError - whileAsync( 'abc', fcn, done ); // $ExpectError - whileAsync( {}, fcn, done ); // $ExpectError - whileAsync( [], fcn, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function having a supported signature... -{ - whileAsync( predicate, 2, done ); // $ExpectError - whileAsync( predicate, false, done ); // $ExpectError - whileAsync( predicate, true, done ); // $ExpectError - whileAsync( predicate, 'abc', done ); // $ExpectError - whileAsync( predicate, {}, done ); // $ExpectError - whileAsync( predicate, [], done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a done callback argument which is not a function having a supported signature... -{ - whileAsync( predicate, fcn, 2 ); // $ExpectError - whileAsync( predicate, fcn, false ); // $ExpectError - whileAsync( predicate, fcn, true ); // $ExpectError - whileAsync( predicate, fcn, 'abc' ); // $ExpectError - whileAsync( predicate, fcn, {} ); // $ExpectError - whileAsync( predicate, fcn, [] ); // $ExpectError - whileAsync( predicate, fcn, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - whileAsync(); // $ExpectError - whileAsync( predicate ); // $ExpectError - whileAsync( predicate, fcn ); // $ExpectError - whileAsync( predicate, fcn, done, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a6af668..0000000 --- a/examples/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var repeatString = require( '@stdlib/string-repeat' ); -var whileAsync = require( './../lib' ); - -function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } -} - -function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, repeatString( 'beep', i+1 ) ); - } -} - -function done( error, result ) { - if ( error ) { - throw error; - } - console.log( result ); -} - -whileAsync( predicate, fcn, done ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..6f152ad --- /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-function@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function n(n,e,o,i){var s,l;if(!r(n))throw new TypeError(t("1Rr3c",n));if(!r(e))throw new TypeError(t("1Rr2H",e));if(!r(o))throw new TypeError(t("1Rr3N",o));function f(r,t){return r?o(r):t?e.call(i,l,h):(s.length&&s.unshift(null),void o.apply(null,s))}function h(r){var t;if(r)return o(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;8LA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a13bd4..0000000 --- a/lib/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Invoke a function while a test condition is true. -* -* @module @stdlib/utils-async-while -* -* @example -* var whileAsync = require( '@stdlib/utils-async-while' ); -* -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c1bab44..0000000 --- a/lib/main.js +++ /dev/null @@ -1,128 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Invokes a function while a test condition is true. -* -* @param {Function} predicate - function which indicates whether to continue invoking a function -* @param {Function} fcn - function to invoke -* @param {Callback} done - callback to invoke upon completion -* @param {*} [thisArg] - execution context for the invoked function -* @throws {TypeError} first argument must be a function -* @throws {TypeError} second argument must be a function -* @throws {TypeError} third argument must be a function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -function whileAsync( predicate, fcn, done, thisArg ) { - var args; - var idx; - if ( !isFunction( predicate ) ) { - throw new TypeError( format( '1Rr3c', predicate ) ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '1Rr2H', fcn ) ); - } - if ( !isFunction( done ) ) { - throw new TypeError( format( '1Rr3N', done ) ); - } - args = []; - idx = 0; - predicate( idx, onPredicate ); - - /** - * Callback invoked upon a predicate result. - * - * @private - * @param {(Error|null)} error - error object - * @param {boolean} result - predicate result - * @returns {void} - */ - function onPredicate( error, result ) { - if ( error ) { - return done( error ); - } - if ( result ) { - return fcn.call( thisArg, idx, next ); - } - if ( args.length ) { - args.unshift( null ); // error argument - } - done.apply( null, args ); - } - - /** - * Callback invoked upon completion of a provided function. - * - * @private - * @param {(Error|null)} error - error object - * @param {...*} results - function results - * @returns {void} - */ - function next( error ) { - var i; - if ( error ) { - return done( error ); - } - idx += 1; - - // Cache the most recent results... - if ( arguments.length > 1 ) { - args = new Array( arguments.length-1 ); - for ( i = 1; i < arguments.length; i++ ) { - args[ i-1 ] = arguments[ i ]; - } - } - // Run the test condition: - predicate( idx, onPredicate ); - } -} - - -// EXPORTS // - -module.exports = whileAsync; diff --git a/package.json b/package.json index a94b816..e1990aa 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Invoke a function while a test condition is true.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/math-base-assert-is-nan": "^0.2.2", - "@stdlib/random-base-randu": "^0.2.1", - "@stdlib/string-repeat": "^0.2.2", - "@stdlib/utils-noop": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..7a166a5 --- /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 78d0688..0000000 --- a/test/test.js +++ /dev/null @@ -1,328 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 whileAsync = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof whileAsync, 'function', 'main export is a function' ); - t.end(); -}); - -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() { - whileAsync( value, noop, 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() { - whileAsync( noop, value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a callback 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() { - whileAsync( noop, noop, value ); - }; - } -}); - -tape( 'while a test condition is true, the function invokes a provided function', function test( t ) { - var indices1 = [ 0, 1, 2, 3, 4, 5 ]; - var indices2 = [ 0, 1, 2, 3, 4 ]; - var j = -1; - var k = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices1[ j ], 'provides expected value' ); - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - k += 1; - t.strictEqual( i, indices2[ k ], 'provides expected value' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'while a test condition is true, the function invokes a provided function (always false)', function test( t ) { - var indices = [ 0 ]; - var j = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices[ j ], 'provides expected value' ); - clbk( null, false ); - } - - function fcn( i, next ) { - t.fail( 'should never be invoked' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx = { - 'count': 0 - }; - - whileAsync( predicate, fcn, done, ctx ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - this.count += 1; // eslint-disable-line no-invalid-this - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( ctx.count, 5, 'updates context' ); - t.end(); - } -}); - -tape( 'the function provides any results to a `done` callback', function test( t ) { - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, 'beep'+i, 'boop'+i, 'woot'+i ); - } - } - - function done( error, str1, str2, str3 ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( str1, 'beep4', 'returns expected value' ); - t.strictEqual( str2, 'boop4', 'returns expected value' ); - t.strictEqual( str3, 'woot4', 'returns expected value' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the predicate function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - if ( i === 1 ) { - return clbk( new Error( 'beep' ) ); - } - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 2, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the provided function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - if ( i === 2 ) { - return next( new Error( 'boop' ) ); - } - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 3, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'the function does not guarantee asynchronous execution', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - k = 1; - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - next(); - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( k, 0, 'releases the zalgo' ); - t.end(); - } -}); From b0b407fef337f3d9644f23d70a599b237072a87b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 01:36:36 +0000 Subject: [PATCH 126/143] 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 1dafc2a..c1bab44 100644 --- a/lib/main.js +++ b/lib/main.js @@ -21,7 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -62,13 +62,13 @@ function whileAsync( predicate, fcn, done, thisArg ) { var args; var idx; if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '1Rr3c', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '1Rr2H', fcn ) ); } if ( !isFunction( done ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', done ) ); + throw new TypeError( format( '1Rr3N', done ) ); } args = []; idx = 0; diff --git a/package.json b/package.json index 77fbf5f..a94b816 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ }, "dependencies": { "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { From e3c65561ce4c9477191ab7da7bd5368b2e23bc41 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 02:43:53 +0000 Subject: [PATCH 127/143] Remove files --- index.d.ts | 127 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4974 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 163e8ba..0000000 --- a/index.d.ts +++ /dev/null @@ -1,127 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Callback function. -*/ -type Nullary = () => void; - -/** -* Callback function. -* -* @param error - encountered error or null -*/ -type Unary = ( error: Error | null ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Binary = ( error: Error | null, bool: boolean ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Callback = Nullary | Unary | Binary; - -/** -* Callback invoked upon completion. -*/ -type DoneNullary = () => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -*/ -type DoneUnary = ( error: Error | null ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneBinary = ( error: Error | null, ...args: Array ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneCallback = DoneNullary | DoneUnary | DoneBinary; - -/** -* Checks whether an element in a collection passes a test. -* -* @param i - iteration number (starting from one) -* @param clbk - a callback indicating whether to invoke `fcn` -*/ -type Predicate = ( i: number, clbk: Callback ) => void; - -/** -* Invoked function. -* -* @param i - iteration number (starting from zero) -* @param next - a callback which must be invoked before proceeding to the next iteration -*/ -type Fcn = ( i: number, next: Function ) => void; - -/** -* Invokes a function while a test condition is true. -* -* @param predicate - function which indicates whether to continue invoking a function -* @param fcn - function to invoke -* @param done - callback to invoke upon completion -* @param thisArg - execution context for the invoked function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -declare function whileAsync( predicate: Predicate, fcn: Fcn, done: DoneCallback, thisArg?: any ): void; - - -// EXPORTS // - -export = whileAsync; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 6f152ad..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-function@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function n(n,e,o,i){var s,l;if(!r(n))throw new TypeError(t("1Rr3c",n));if(!r(e))throw new TypeError(t("1Rr2H",e));if(!r(o))throw new TypeError(t("1Rr3N",o));function f(r,t){return r?o(r):t?e.call(i,l,h):(s.length&&s.unshift(null),void o.apply(null,s))}function h(r){var t;if(r)return o(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;8LA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 7a166a5..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From cd18c6cbb50932da008c8cf92c818bd74303eede Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 02:44:09 +0000 Subject: [PATCH 128/143] 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 | 204 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 105 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 72 - docs/types/test.ts | 83 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 57 - lib/main.js | 128 - package.json | 57 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 328 -- 43 files changed, 4867 insertions(+), 4389 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 (100%) 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 f0c6b3d..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-09-01T01:17:40.782Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 0f8dec8..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/async/while) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 9633c26..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/async/while) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 0bdf3fd..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: '8 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' - # 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 + + ```
@@ -292,7 +283,7 @@ whileAsync( predicate, fcn, done ); ## 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]. @@ -357,13 +348,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until +[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until/tree/esm -[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while +[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while/tree/esm -[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until +[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until/tree/esm -[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while +[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while/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 7c83acf..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var whileAsync = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); - -bench( pkg+'::sync_predicate', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2c3ed87..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/async/while" -%% click B href "https://github.com/stdlib-js/utils-async-while/tree/main" -%% click C href "https://github.com/stdlib-js/utils-async-while/tree/production" -%% click D href "https://github.com/stdlib-js/utils-async-while/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-async-while/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-async-while/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/async/while -[production-url]: https://github.com/stdlib-js/utils-async-while/tree/production -[deno-url]: https://github.com/stdlib-js/utils-async-while/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-async-while/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-async-while/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-async-while/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-async-while/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-async-while/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 efdafdf..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import whileAsync from '../docs/types/index'; -export = whileAsync; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 159efee..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var v=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var m=v(function(p,g){ -var s=require('@stdlib/assert-is-function/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist');function c(t,r,e,o){var u,i;if(!s(t))throw new TypeError(l('1Rr3c',t));if(!s(r))throw new TypeError(l('1Rr2H',r));if(!s(e))throw new TypeError(l('1Rr3N',e));u=[],i=0,t(i,f);function f(a,n){if(a)return e(a);if(n)return r.call(o,i,h);u.length&&u.unshift(null),e.apply(null,u)}function h(a){var n;if(a)return e(a);if(i+=1,arguments.length>1)for(u=new Array(arguments.length-1),n=1;n 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = whileAsync;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Invoke a function while a test condition is true.\n*\n* @module @stdlib/utils-async-while\n*\n* @example\n* var whileAsync = require( '@stdlib/utils-async-while' );\n*\n* function predicate( i, clbk ) {\n* clbk( null, i < 5 );\n* }\n*\n* function fcn( i, next ) {\n* setTimeout( onTimeout, i );\n* function onTimeout() {\n* console.log( 'beep: %d', i );\n* next();\n* }\n* }\n*\n* function done( error ) {\n* if ( error ) {\n* throw error;\n* }\n* }\n*\n* whileAsync( predicate, fcn, done );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAS,QAAS,uBAAwB,EAqC9C,SAASC,EAAYC,EAAWC,EAAKC,EAAMC,EAAU,CACpD,IAAIC,EACAC,EACJ,GAAK,CAACR,EAAYG,CAAU,EAC3B,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAU,CAAE,EAE/G,GAAK,CAACH,EAAYI,CAAI,EACrB,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAI,CAAE,EAE1G,GAAK,CAACJ,EAAYK,CAAK,EACtB,MAAM,IAAI,UAAWJ,EAAQ,oEAAqEI,CAAK,CAAE,EAE1GE,EAAO,CAAC,EACRC,EAAM,EACNL,EAAWK,EAAKC,CAAY,EAU5B,SAASA,EAAaC,EAAOC,EAAS,CACrC,GAAKD,EACJ,OAAOL,EAAMK,CAAM,EAEpB,GAAKC,EACJ,OAAOP,EAAI,KAAME,EAASE,EAAKI,CAAK,EAEhCL,EAAK,QACTA,EAAK,QAAS,IAAK,EAEpBF,EAAK,MAAO,KAAME,CAAK,CACxB,CAUA,SAASK,EAAMF,EAAQ,CACtB,IAAIG,EACJ,GAAKH,EACJ,OAAOL,EAAMK,CAAM,EAKpB,GAHAF,GAAO,EAGF,UAAU,OAAS,EAEvB,IADAD,EAAO,IAAI,MAAO,UAAU,OAAO,CAAE,EAC/BM,EAAI,EAAGA,EAAI,UAAU,OAAQA,IAClCN,EAAMM,EAAE,CAAE,EAAI,UAAWA,CAAE,EAI7BV,EAAWK,EAAKC,CAAY,CAC7B,CACD,CAKAV,EAAO,QAAUG,IC5EjB,IAAIY,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "format", "whileAsync", "predicate", "fcn", "done", "thisArg", "args", "idx", "onPredicate", "error", "result", "next", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index d7ca8c9..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,72 +0,0 @@ - -{{alias}}( predicate, fcn, done[, thisArg] ) - Invokes a function while a test condition is true. - - The predicate function is provided two arguments: - - - `i`: iteration number (starting from zero) - - `clbk`: a callback indicating whether to invoke `fcn` - - The `clbk` function accepts two arguments: - - - `error`: error argument - - `bool`: test result - - If the test result is truthy, the function invokes `fcn`; otherwise, the - function invokes the `done` callback. - - The function to invoke is provided two arguments: - - - `i`: iteration number (starting from zero) - - `next`: a callback which must be invoked before proceeding to the next - iteration - - The first argument of the `next` callback is an `error` argument. If `fcn` - calls the `next` callback with a truthy `error` argument, the function - suspends execution and immediately calls the `done` callback for subsequent - `error` handling. - - The `done` callback is invoked with an `error` argument and any arguments - passed to the final `next` callback. - - Execution is *not* guaranteed to be asynchronous. To guarantee asynchrony, - wrap the `done` callback in a function which either executes at the end of - the current stack (e.g., `nextTick`) or during a subsequent turn of the - event loop (e.g., `setImmediate`, `setTimeout`). - - Parameters - ---------- - predicate: Function - The predicate function which indicates whether to continue invoking a - function. - - fcn: Function - The function to invoke. - - done: Function - Callback to invoke upon completion. - - thisArg: any (optional) - Execution context for the invoked function. - - Examples - -------- - > function predicate( i, clbk ) { clbk( null, i < 5 ); }; - > function fcn( i, next ) { - ... setTimeout( onTimeout, i ); - ... function onTimeout() { - ... next( null, 'boop'+i ); - ... } - ... }; - > function done( error, result ) { - ... if ( error ) { - ... throw error; - ... } - ... console.log( result ); - ... }; - > {{alias}}( predicate, fcn, done ) - boop: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4a543d9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,83 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 whileAsync = require( './index' ); - -const fcn = ( i: number, next: Function ): void => { - if ( i === void 0 ) { - throw new Error( '`i` is missing.' ); - } - next(); -}; - -const predicate = ( i: number, clbk: Function ): void => { - clbk( null, i < 5 ); -}; - -const done = ( error: Error | null ): void => { - if ( error ) { - throw error; - } -}; - - -// TESTS // - -// The function returns void... -{ - whileAsync( predicate, fcn, done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a predicate function... -{ - whileAsync( 2, fcn, done ); // $ExpectError - whileAsync( false, fcn, done ); // $ExpectError - whileAsync( true, fcn, done ); // $ExpectError - whileAsync( 'abc', fcn, done ); // $ExpectError - whileAsync( {}, fcn, done ); // $ExpectError - whileAsync( [], fcn, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function having a supported signature... -{ - whileAsync( predicate, 2, done ); // $ExpectError - whileAsync( predicate, false, done ); // $ExpectError - whileAsync( predicate, true, done ); // $ExpectError - whileAsync( predicate, 'abc', done ); // $ExpectError - whileAsync( predicate, {}, done ); // $ExpectError - whileAsync( predicate, [], done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a done callback argument which is not a function having a supported signature... -{ - whileAsync( predicate, fcn, 2 ); // $ExpectError - whileAsync( predicate, fcn, false ); // $ExpectError - whileAsync( predicate, fcn, true ); // $ExpectError - whileAsync( predicate, fcn, 'abc' ); // $ExpectError - whileAsync( predicate, fcn, {} ); // $ExpectError - whileAsync( predicate, fcn, [] ); // $ExpectError - whileAsync( predicate, fcn, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - whileAsync(); // $ExpectError - whileAsync( predicate ); // $ExpectError - whileAsync( predicate, fcn ); // $ExpectError - whileAsync( predicate, fcn, done, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a6af668..0000000 --- a/examples/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var repeatString = require( '@stdlib/string-repeat' ); -var whileAsync = require( './../lib' ); - -function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } -} - -function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, repeatString( 'beep', i+1 ) ); - } -} - -function done( error, result ) { - if ( error ) { - throw error; - } - console.log( result ); -} - -whileAsync( predicate, fcn, done ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..6f152ad --- /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-function@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function n(n,e,o,i){var s,l;if(!r(n))throw new TypeError(t("1Rr3c",n));if(!r(e))throw new TypeError(t("1Rr2H",e));if(!r(o))throw new TypeError(t("1Rr3N",o));function f(r,t){return r?o(r):t?e.call(i,l,h):(s.length&&s.unshift(null),void o.apply(null,s))}function h(r){var t;if(r)return o(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;8LA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a13bd4..0000000 --- a/lib/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Invoke a function while a test condition is true. -* -* @module @stdlib/utils-async-while -* -* @example -* var whileAsync = require( '@stdlib/utils-async-while' ); -* -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c1bab44..0000000 --- a/lib/main.js +++ /dev/null @@ -1,128 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Invokes a function while a test condition is true. -* -* @param {Function} predicate - function which indicates whether to continue invoking a function -* @param {Function} fcn - function to invoke -* @param {Callback} done - callback to invoke upon completion -* @param {*} [thisArg] - execution context for the invoked function -* @throws {TypeError} first argument must be a function -* @throws {TypeError} second argument must be a function -* @throws {TypeError} third argument must be a function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -function whileAsync( predicate, fcn, done, thisArg ) { - var args; - var idx; - if ( !isFunction( predicate ) ) { - throw new TypeError( format( '1Rr3c', predicate ) ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '1Rr2H', fcn ) ); - } - if ( !isFunction( done ) ) { - throw new TypeError( format( '1Rr3N', done ) ); - } - args = []; - idx = 0; - predicate( idx, onPredicate ); - - /** - * Callback invoked upon a predicate result. - * - * @private - * @param {(Error|null)} error - error object - * @param {boolean} result - predicate result - * @returns {void} - */ - function onPredicate( error, result ) { - if ( error ) { - return done( error ); - } - if ( result ) { - return fcn.call( thisArg, idx, next ); - } - if ( args.length ) { - args.unshift( null ); // error argument - } - done.apply( null, args ); - } - - /** - * Callback invoked upon completion of a provided function. - * - * @private - * @param {(Error|null)} error - error object - * @param {...*} results - function results - * @returns {void} - */ - function next( error ) { - var i; - if ( error ) { - return done( error ); - } - idx += 1; - - // Cache the most recent results... - if ( arguments.length > 1 ) { - args = new Array( arguments.length-1 ); - for ( i = 1; i < arguments.length; i++ ) { - args[ i-1 ] = arguments[ i ]; - } - } - // Run the test condition: - predicate( idx, onPredicate ); - } -} - - -// EXPORTS // - -module.exports = whileAsync; diff --git a/package.json b/package.json index a94b816..e1990aa 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Invoke a function while a test condition is true.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/math-base-assert-is-nan": "^0.2.2", - "@stdlib/random-base-randu": "^0.2.1", - "@stdlib/string-repeat": "^0.2.2", - "@stdlib/utils-noop": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..7a166a5 --- /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 78d0688..0000000 --- a/test/test.js +++ /dev/null @@ -1,328 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 whileAsync = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof whileAsync, 'function', 'main export is a function' ); - t.end(); -}); - -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() { - whileAsync( value, noop, 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() { - whileAsync( noop, value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a callback 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() { - whileAsync( noop, noop, value ); - }; - } -}); - -tape( 'while a test condition is true, the function invokes a provided function', function test( t ) { - var indices1 = [ 0, 1, 2, 3, 4, 5 ]; - var indices2 = [ 0, 1, 2, 3, 4 ]; - var j = -1; - var k = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices1[ j ], 'provides expected value' ); - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - k += 1; - t.strictEqual( i, indices2[ k ], 'provides expected value' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'while a test condition is true, the function invokes a provided function (always false)', function test( t ) { - var indices = [ 0 ]; - var j = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices[ j ], 'provides expected value' ); - clbk( null, false ); - } - - function fcn( i, next ) { - t.fail( 'should never be invoked' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx = { - 'count': 0 - }; - - whileAsync( predicate, fcn, done, ctx ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - this.count += 1; // eslint-disable-line no-invalid-this - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( ctx.count, 5, 'updates context' ); - t.end(); - } -}); - -tape( 'the function provides any results to a `done` callback', function test( t ) { - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, 'beep'+i, 'boop'+i, 'woot'+i ); - } - } - - function done( error, str1, str2, str3 ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( str1, 'beep4', 'returns expected value' ); - t.strictEqual( str2, 'boop4', 'returns expected value' ); - t.strictEqual( str3, 'woot4', 'returns expected value' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the predicate function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - if ( i === 1 ) { - return clbk( new Error( 'beep' ) ); - } - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 2, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the provided function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - if ( i === 2 ) { - return next( new Error( 'boop' ) ); - } - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 3, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'the function does not guarantee asynchronous execution', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - k = 1; - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - next(); - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( k, 0, 'releases the zalgo' ); - t.end(); - } -}); From 372a241f67fb0049677f2c15c94f3d4bd4916007 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 21 Sep 2024 21:52:57 +0000 Subject: [PATCH 129/143] 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 1dafc2a..c1bab44 100644 --- a/lib/main.js +++ b/lib/main.js @@ -21,7 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -62,13 +62,13 @@ function whileAsync( predicate, fcn, done, thisArg ) { var args; var idx; if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '1Rr3c', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '1Rr2H', fcn ) ); } if ( !isFunction( done ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', done ) ); + throw new TypeError( format( '1Rr3N', done ) ); } args = []; idx = 0; diff --git a/package.json b/package.json index 77fbf5f..a94b816 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ }, "dependencies": { "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { From 0bf1174453aef6d308ffd592d955fa66a4be174f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 21 Sep 2024 22:18:34 +0000 Subject: [PATCH 130/143] Remove files --- index.d.ts | 127 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4974 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 163e8ba..0000000 --- a/index.d.ts +++ /dev/null @@ -1,127 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Callback function. -*/ -type Nullary = () => void; - -/** -* Callback function. -* -* @param error - encountered error or null -*/ -type Unary = ( error: Error | null ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Binary = ( error: Error | null, bool: boolean ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Callback = Nullary | Unary | Binary; - -/** -* Callback invoked upon completion. -*/ -type DoneNullary = () => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -*/ -type DoneUnary = ( error: Error | null ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneBinary = ( error: Error | null, ...args: Array ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneCallback = DoneNullary | DoneUnary | DoneBinary; - -/** -* Checks whether an element in a collection passes a test. -* -* @param i - iteration number (starting from one) -* @param clbk - a callback indicating whether to invoke `fcn` -*/ -type Predicate = ( i: number, clbk: Callback ) => void; - -/** -* Invoked function. -* -* @param i - iteration number (starting from zero) -* @param next - a callback which must be invoked before proceeding to the next iteration -*/ -type Fcn = ( i: number, next: Function ) => void; - -/** -* Invokes a function while a test condition is true. -* -* @param predicate - function which indicates whether to continue invoking a function -* @param fcn - function to invoke -* @param done - callback to invoke upon completion -* @param thisArg - execution context for the invoked function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -declare function whileAsync( predicate: Predicate, fcn: Fcn, done: DoneCallback, thisArg?: any ): void; - - -// EXPORTS // - -export = whileAsync; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 6f152ad..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-function@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function n(n,e,o,i){var s,l;if(!r(n))throw new TypeError(t("1Rr3c",n));if(!r(e))throw new TypeError(t("1Rr2H",e));if(!r(o))throw new TypeError(t("1Rr3N",o));function f(r,t){return r?o(r):t?e.call(i,l,h):(s.length&&s.unshift(null),void o.apply(null,s))}function h(r){var t;if(r)return o(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;8LA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 7a166a5..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From afafaae7e190c35ac8c2bfd0428e2bb79c25aa35 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 21 Sep 2024 22:18:48 +0000 Subject: [PATCH 131/143] 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 | 238 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 105 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 72 - docs/types/test.ts | 83 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 57 - lib/main.js | 128 - package.json | 57 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 328 -- 42 files changed, 4867 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 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 (100%) 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 0f8dec8..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/async/while) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 9633c26..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/async/while) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 0bdf3fd..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: '8 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' - # 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 + + ```
@@ -292,7 +283,7 @@ whileAsync( predicate, fcn, done ); ## 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]. @@ -357,13 +348,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until +[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until/tree/esm -[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while +[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while/tree/esm -[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until +[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until/tree/esm -[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while +[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while/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 7c83acf..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var whileAsync = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); - -bench( pkg+'::sync_predicate', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2c3ed87..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/async/while" -%% click B href "https://github.com/stdlib-js/utils-async-while/tree/main" -%% click C href "https://github.com/stdlib-js/utils-async-while/tree/production" -%% click D href "https://github.com/stdlib-js/utils-async-while/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-async-while/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-async-while/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/async/while -[production-url]: https://github.com/stdlib-js/utils-async-while/tree/production -[deno-url]: https://github.com/stdlib-js/utils-async-while/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-async-while/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-async-while/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-async-while/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-async-while/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-async-while/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 efdafdf..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import whileAsync from '../docs/types/index'; -export = whileAsync; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 159efee..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var v=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var m=v(function(p,g){ -var s=require('@stdlib/assert-is-function/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist');function c(t,r,e,o){var u,i;if(!s(t))throw new TypeError(l('1Rr3c',t));if(!s(r))throw new TypeError(l('1Rr2H',r));if(!s(e))throw new TypeError(l('1Rr3N',e));u=[],i=0,t(i,f);function f(a,n){if(a)return e(a);if(n)return r.call(o,i,h);u.length&&u.unshift(null),e.apply(null,u)}function h(a){var n;if(a)return e(a);if(i+=1,arguments.length>1)for(u=new Array(arguments.length-1),n=1;n 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = whileAsync;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Invoke a function while a test condition is true.\n*\n* @module @stdlib/utils-async-while\n*\n* @example\n* var whileAsync = require( '@stdlib/utils-async-while' );\n*\n* function predicate( i, clbk ) {\n* clbk( null, i < 5 );\n* }\n*\n* function fcn( i, next ) {\n* setTimeout( onTimeout, i );\n* function onTimeout() {\n* console.log( 'beep: %d', i );\n* next();\n* }\n* }\n*\n* function done( error ) {\n* if ( error ) {\n* throw error;\n* }\n* }\n*\n* whileAsync( predicate, fcn, done );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAS,QAAS,uBAAwB,EAqC9C,SAASC,EAAYC,EAAWC,EAAKC,EAAMC,EAAU,CACpD,IAAIC,EACAC,EACJ,GAAK,CAACR,EAAYG,CAAU,EAC3B,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAU,CAAE,EAE/G,GAAK,CAACH,EAAYI,CAAI,EACrB,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAI,CAAE,EAE1G,GAAK,CAACJ,EAAYK,CAAK,EACtB,MAAM,IAAI,UAAWJ,EAAQ,oEAAqEI,CAAK,CAAE,EAE1GE,EAAO,CAAC,EACRC,EAAM,EACNL,EAAWK,EAAKC,CAAY,EAU5B,SAASA,EAAaC,EAAOC,EAAS,CACrC,GAAKD,EACJ,OAAOL,EAAMK,CAAM,EAEpB,GAAKC,EACJ,OAAOP,EAAI,KAAME,EAASE,EAAKI,CAAK,EAEhCL,EAAK,QACTA,EAAK,QAAS,IAAK,EAEpBF,EAAK,MAAO,KAAME,CAAK,CACxB,CAUA,SAASK,EAAMF,EAAQ,CACtB,IAAIG,EACJ,GAAKH,EACJ,OAAOL,EAAMK,CAAM,EAKpB,GAHAF,GAAO,EAGF,UAAU,OAAS,EAEvB,IADAD,EAAO,IAAI,MAAO,UAAU,OAAO,CAAE,EAC/BM,EAAI,EAAGA,EAAI,UAAU,OAAQA,IAClCN,EAAMM,EAAE,CAAE,EAAI,UAAWA,CAAE,EAI7BV,EAAWK,EAAKC,CAAY,CAC7B,CACD,CAKAV,EAAO,QAAUG,IC5EjB,IAAIY,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "format", "whileAsync", "predicate", "fcn", "done", "thisArg", "args", "idx", "onPredicate", "error", "result", "next", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 960d0a1..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,72 +0,0 @@ - -{{alias}}( predicate, fcn, done[, thisArg] ) - Invokes a function while a test condition is true. - - The predicate function is provided two arguments: - - - i: iteration number (starting from zero). - - clbk: a callback indicating whether to invoke `fcn`. - - The `clbk` function accepts two arguments: - - - error: error argument. - - bool: test result. - - If the test result is truthy, the function invokes `fcn`; otherwise, the - function invokes the `done` callback. - - The function to invoke is provided two arguments: - - - i: iteration number (starting from zero). - - next: a callback which must be invoked before proceeding to the next - iteration. - - The first argument of the `next` callback is an `error` argument. If `fcn` - calls the `next` callback with a truthy `error` argument, the function - suspends execution and immediately calls the `done` callback for subsequent - `error` handling. - - The `done` callback is invoked with an `error` argument and any arguments - passed to the final `next` callback. - - Execution is *not* guaranteed to be asynchronous. To guarantee asynchrony, - wrap the `done` callback in a function which either executes at the end of - the current stack (e.g., `nextTick`) or during a subsequent turn of the - event loop (e.g., `setImmediate`, `setTimeout`). - - Parameters - ---------- - predicate: Function - The predicate function which indicates whether to continue invoking a - function. - - fcn: Function - The function to invoke. - - done: Function - Callback to invoke upon completion. - - thisArg: any (optional) - Execution context for the invoked function. - - Examples - -------- - > function predicate( i, clbk ) { clbk( null, i < 5 ); }; - > function fcn( i, next ) { - ... setTimeout( onTimeout, i ); - ... function onTimeout() { - ... next( null, 'boop'+i ); - ... } - ... }; - > function done( error, result ) { - ... if ( error ) { - ... throw error; - ... } - ... console.log( result ); - ... }; - > {{alias}}( predicate, fcn, done ) - boop: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4a543d9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,83 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 whileAsync = require( './index' ); - -const fcn = ( i: number, next: Function ): void => { - if ( i === void 0 ) { - throw new Error( '`i` is missing.' ); - } - next(); -}; - -const predicate = ( i: number, clbk: Function ): void => { - clbk( null, i < 5 ); -}; - -const done = ( error: Error | null ): void => { - if ( error ) { - throw error; - } -}; - - -// TESTS // - -// The function returns void... -{ - whileAsync( predicate, fcn, done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a predicate function... -{ - whileAsync( 2, fcn, done ); // $ExpectError - whileAsync( false, fcn, done ); // $ExpectError - whileAsync( true, fcn, done ); // $ExpectError - whileAsync( 'abc', fcn, done ); // $ExpectError - whileAsync( {}, fcn, done ); // $ExpectError - whileAsync( [], fcn, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function having a supported signature... -{ - whileAsync( predicate, 2, done ); // $ExpectError - whileAsync( predicate, false, done ); // $ExpectError - whileAsync( predicate, true, done ); // $ExpectError - whileAsync( predicate, 'abc', done ); // $ExpectError - whileAsync( predicate, {}, done ); // $ExpectError - whileAsync( predicate, [], done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a done callback argument which is not a function having a supported signature... -{ - whileAsync( predicate, fcn, 2 ); // $ExpectError - whileAsync( predicate, fcn, false ); // $ExpectError - whileAsync( predicate, fcn, true ); // $ExpectError - whileAsync( predicate, fcn, 'abc' ); // $ExpectError - whileAsync( predicate, fcn, {} ); // $ExpectError - whileAsync( predicate, fcn, [] ); // $ExpectError - whileAsync( predicate, fcn, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - whileAsync(); // $ExpectError - whileAsync( predicate ); // $ExpectError - whileAsync( predicate, fcn ); // $ExpectError - whileAsync( predicate, fcn, done, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a6af668..0000000 --- a/examples/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var repeatString = require( '@stdlib/string-repeat' ); -var whileAsync = require( './../lib' ); - -function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } -} - -function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, repeatString( 'beep', i+1 ) ); - } -} - -function done( error, result ) { - if ( error ) { - throw error; - } - console.log( result ); -} - -whileAsync( predicate, fcn, done ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..6f152ad --- /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-function@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function n(n,e,o,i){var s,l;if(!r(n))throw new TypeError(t("1Rr3c",n));if(!r(e))throw new TypeError(t("1Rr2H",e));if(!r(o))throw new TypeError(t("1Rr3N",o));function f(r,t){return r?o(r):t?e.call(i,l,h):(s.length&&s.unshift(null),void o.apply(null,s))}function h(r){var t;if(r)return o(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;8LA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a13bd4..0000000 --- a/lib/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Invoke a function while a test condition is true. -* -* @module @stdlib/utils-async-while -* -* @example -* var whileAsync = require( '@stdlib/utils-async-while' ); -* -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c1bab44..0000000 --- a/lib/main.js +++ /dev/null @@ -1,128 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Invokes a function while a test condition is true. -* -* @param {Function} predicate - function which indicates whether to continue invoking a function -* @param {Function} fcn - function to invoke -* @param {Callback} done - callback to invoke upon completion -* @param {*} [thisArg] - execution context for the invoked function -* @throws {TypeError} first argument must be a function -* @throws {TypeError} second argument must be a function -* @throws {TypeError} third argument must be a function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -function whileAsync( predicate, fcn, done, thisArg ) { - var args; - var idx; - if ( !isFunction( predicate ) ) { - throw new TypeError( format( '1Rr3c', predicate ) ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '1Rr2H', fcn ) ); - } - if ( !isFunction( done ) ) { - throw new TypeError( format( '1Rr3N', done ) ); - } - args = []; - idx = 0; - predicate( idx, onPredicate ); - - /** - * Callback invoked upon a predicate result. - * - * @private - * @param {(Error|null)} error - error object - * @param {boolean} result - predicate result - * @returns {void} - */ - function onPredicate( error, result ) { - if ( error ) { - return done( error ); - } - if ( result ) { - return fcn.call( thisArg, idx, next ); - } - if ( args.length ) { - args.unshift( null ); // error argument - } - done.apply( null, args ); - } - - /** - * Callback invoked upon completion of a provided function. - * - * @private - * @param {(Error|null)} error - error object - * @param {...*} results - function results - * @returns {void} - */ - function next( error ) { - var i; - if ( error ) { - return done( error ); - } - idx += 1; - - // Cache the most recent results... - if ( arguments.length > 1 ) { - args = new Array( arguments.length-1 ); - for ( i = 1; i < arguments.length; i++ ) { - args[ i-1 ] = arguments[ i ]; - } - } - // Run the test condition: - predicate( idx, onPredicate ); - } -} - - -// EXPORTS // - -module.exports = whileAsync; diff --git a/package.json b/package.json index a94b816..e1990aa 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Invoke a function while a test condition is true.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/math-base-assert-is-nan": "^0.2.2", - "@stdlib/random-base-randu": "^0.2.1", - "@stdlib/string-repeat": "^0.2.2", - "@stdlib/utils-noop": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..7a166a5 --- /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 78d0688..0000000 --- a/test/test.js +++ /dev/null @@ -1,328 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 whileAsync = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof whileAsync, 'function', 'main export is a function' ); - t.end(); -}); - -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() { - whileAsync( value, noop, 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() { - whileAsync( noop, value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a callback 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() { - whileAsync( noop, noop, value ); - }; - } -}); - -tape( 'while a test condition is true, the function invokes a provided function', function test( t ) { - var indices1 = [ 0, 1, 2, 3, 4, 5 ]; - var indices2 = [ 0, 1, 2, 3, 4 ]; - var j = -1; - var k = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices1[ j ], 'provides expected value' ); - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - k += 1; - t.strictEqual( i, indices2[ k ], 'provides expected value' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'while a test condition is true, the function invokes a provided function (always false)', function test( t ) { - var indices = [ 0 ]; - var j = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices[ j ], 'provides expected value' ); - clbk( null, false ); - } - - function fcn( i, next ) { - t.fail( 'should never be invoked' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx = { - 'count': 0 - }; - - whileAsync( predicate, fcn, done, ctx ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - this.count += 1; // eslint-disable-line no-invalid-this - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( ctx.count, 5, 'updates context' ); - t.end(); - } -}); - -tape( 'the function provides any results to a `done` callback', function test( t ) { - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, 'beep'+i, 'boop'+i, 'woot'+i ); - } - } - - function done( error, str1, str2, str3 ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( str1, 'beep4', 'returns expected value' ); - t.strictEqual( str2, 'boop4', 'returns expected value' ); - t.strictEqual( str3, 'woot4', 'returns expected value' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the predicate function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - if ( i === 1 ) { - return clbk( new Error( 'beep' ) ); - } - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 2, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the provided function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - if ( i === 2 ) { - return next( new Error( 'boop' ) ); - } - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 3, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'the function does not guarantee asynchronous execution', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - k = 1; - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - next(); - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( k, 0, 'releases the zalgo' ); - t.end(); - } -}); From 113dbef717c9fe46d00eb1653daf3e2d04ebe285 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 01:40:41 +0000 Subject: [PATCH 132/143] 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 1dafc2a..c1bab44 100644 --- a/lib/main.js +++ b/lib/main.js @@ -21,7 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -62,13 +62,13 @@ function whileAsync( predicate, fcn, done, thisArg ) { var args; var idx; if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '1Rr3c', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '1Rr2H', fcn ) ); } if ( !isFunction( done ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', done ) ); + throw new TypeError( format( '1Rr3N', done ) ); } args = []; idx = 0; diff --git a/package.json b/package.json index 77fbf5f..a94b816 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ }, "dependencies": { "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { From 101c89c36e8de733e30c9359b509fba348c7a062 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 02:40:37 +0000 Subject: [PATCH 133/143] Remove files --- index.d.ts | 127 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4974 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 163e8ba..0000000 --- a/index.d.ts +++ /dev/null @@ -1,127 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Callback function. -*/ -type Nullary = () => void; - -/** -* Callback function. -* -* @param error - encountered error or null -*/ -type Unary = ( error: Error | null ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Binary = ( error: Error | null, bool: boolean ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Callback = Nullary | Unary | Binary; - -/** -* Callback invoked upon completion. -*/ -type DoneNullary = () => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -*/ -type DoneUnary = ( error: Error | null ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneBinary = ( error: Error | null, ...args: Array ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneCallback = DoneNullary | DoneUnary | DoneBinary; - -/** -* Checks whether an element in a collection passes a test. -* -* @param i - iteration number (starting from one) -* @param clbk - a callback indicating whether to invoke `fcn` -*/ -type Predicate = ( i: number, clbk: Callback ) => void; - -/** -* Invoked function. -* -* @param i - iteration number (starting from zero) -* @param next - a callback which must be invoked before proceeding to the next iteration -*/ -type Fcn = ( i: number, next: Function ) => void; - -/** -* Invokes a function while a test condition is true. -* -* @param predicate - function which indicates whether to continue invoking a function -* @param fcn - function to invoke -* @param done - callback to invoke upon completion -* @param thisArg - execution context for the invoked function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -declare function whileAsync( predicate: Predicate, fcn: Fcn, done: DoneCallback, thisArg?: any ): void; - - -// EXPORTS // - -export = whileAsync; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 6f152ad..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-function@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function n(n,e,o,i){var s,l;if(!r(n))throw new TypeError(t("1Rr3c",n));if(!r(e))throw new TypeError(t("1Rr2H",e));if(!r(o))throw new TypeError(t("1Rr3N",o));function f(r,t){return r?o(r):t?e.call(i,l,h):(s.length&&s.unshift(null),void o.apply(null,s))}function h(r){var t;if(r)return o(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;8LA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 7a166a5..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 72e3ce4b981b90298483fa2a708b7af747493b7e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 02:40:57 +0000 Subject: [PATCH 134/143] 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 | 238 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 105 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 72 - docs/types/test.ts | 83 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 57 - lib/main.js | 128 - package.json | 57 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 328 -- 43 files changed, 4867 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 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 (100%) 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 32a9862..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-10-01T01:23:40.798Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 0f8dec8..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/async/while) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 9633c26..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/async/while) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 0bdf3fd..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: '8 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' - # 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 + + ```
@@ -292,7 +283,7 @@ whileAsync( predicate, fcn, done ); ## 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]. @@ -357,13 +348,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until +[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until/tree/esm -[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while +[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while/tree/esm -[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until +[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until/tree/esm -[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while +[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while/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 7c83acf..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var whileAsync = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); - -bench( pkg+'::sync_predicate', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2c3ed87..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/async/while" -%% click B href "https://github.com/stdlib-js/utils-async-while/tree/main" -%% click C href "https://github.com/stdlib-js/utils-async-while/tree/production" -%% click D href "https://github.com/stdlib-js/utils-async-while/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-async-while/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-async-while/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/async/while -[production-url]: https://github.com/stdlib-js/utils-async-while/tree/production -[deno-url]: https://github.com/stdlib-js/utils-async-while/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-async-while/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-async-while/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-async-while/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-async-while/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-async-while/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 efdafdf..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import whileAsync from '../docs/types/index'; -export = whileAsync; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 159efee..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var v=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var m=v(function(p,g){ -var s=require('@stdlib/assert-is-function/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist');function c(t,r,e,o){var u,i;if(!s(t))throw new TypeError(l('1Rr3c',t));if(!s(r))throw new TypeError(l('1Rr2H',r));if(!s(e))throw new TypeError(l('1Rr3N',e));u=[],i=0,t(i,f);function f(a,n){if(a)return e(a);if(n)return r.call(o,i,h);u.length&&u.unshift(null),e.apply(null,u)}function h(a){var n;if(a)return e(a);if(i+=1,arguments.length>1)for(u=new Array(arguments.length-1),n=1;n 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = whileAsync;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Invoke a function while a test condition is true.\n*\n* @module @stdlib/utils-async-while\n*\n* @example\n* var whileAsync = require( '@stdlib/utils-async-while' );\n*\n* function predicate( i, clbk ) {\n* clbk( null, i < 5 );\n* }\n*\n* function fcn( i, next ) {\n* setTimeout( onTimeout, i );\n* function onTimeout() {\n* console.log( 'beep: %d', i );\n* next();\n* }\n* }\n*\n* function done( error ) {\n* if ( error ) {\n* throw error;\n* }\n* }\n*\n* whileAsync( predicate, fcn, done );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAS,QAAS,uBAAwB,EAqC9C,SAASC,EAAYC,EAAWC,EAAKC,EAAMC,EAAU,CACpD,IAAIC,EACAC,EACJ,GAAK,CAACR,EAAYG,CAAU,EAC3B,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAU,CAAE,EAE/G,GAAK,CAACH,EAAYI,CAAI,EACrB,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAI,CAAE,EAE1G,GAAK,CAACJ,EAAYK,CAAK,EACtB,MAAM,IAAI,UAAWJ,EAAQ,oEAAqEI,CAAK,CAAE,EAE1GE,EAAO,CAAC,EACRC,EAAM,EACNL,EAAWK,EAAKC,CAAY,EAU5B,SAASA,EAAaC,EAAOC,EAAS,CACrC,GAAKD,EACJ,OAAOL,EAAMK,CAAM,EAEpB,GAAKC,EACJ,OAAOP,EAAI,KAAME,EAASE,EAAKI,CAAK,EAEhCL,EAAK,QACTA,EAAK,QAAS,IAAK,EAEpBF,EAAK,MAAO,KAAME,CAAK,CACxB,CAUA,SAASK,EAAMF,EAAQ,CACtB,IAAIG,EACJ,GAAKH,EACJ,OAAOL,EAAMK,CAAM,EAKpB,GAHAF,GAAO,EAGF,UAAU,OAAS,EAEvB,IADAD,EAAO,IAAI,MAAO,UAAU,OAAO,CAAE,EAC/BM,EAAI,EAAGA,EAAI,UAAU,OAAQA,IAClCN,EAAMM,EAAE,CAAE,EAAI,UAAWA,CAAE,EAI7BV,EAAWK,EAAKC,CAAY,CAC7B,CACD,CAKAV,EAAO,QAAUG,IC5EjB,IAAIY,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "format", "whileAsync", "predicate", "fcn", "done", "thisArg", "args", "idx", "onPredicate", "error", "result", "next", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 960d0a1..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,72 +0,0 @@ - -{{alias}}( predicate, fcn, done[, thisArg] ) - Invokes a function while a test condition is true. - - The predicate function is provided two arguments: - - - i: iteration number (starting from zero). - - clbk: a callback indicating whether to invoke `fcn`. - - The `clbk` function accepts two arguments: - - - error: error argument. - - bool: test result. - - If the test result is truthy, the function invokes `fcn`; otherwise, the - function invokes the `done` callback. - - The function to invoke is provided two arguments: - - - i: iteration number (starting from zero). - - next: a callback which must be invoked before proceeding to the next - iteration. - - The first argument of the `next` callback is an `error` argument. If `fcn` - calls the `next` callback with a truthy `error` argument, the function - suspends execution and immediately calls the `done` callback for subsequent - `error` handling. - - The `done` callback is invoked with an `error` argument and any arguments - passed to the final `next` callback. - - Execution is *not* guaranteed to be asynchronous. To guarantee asynchrony, - wrap the `done` callback in a function which either executes at the end of - the current stack (e.g., `nextTick`) or during a subsequent turn of the - event loop (e.g., `setImmediate`, `setTimeout`). - - Parameters - ---------- - predicate: Function - The predicate function which indicates whether to continue invoking a - function. - - fcn: Function - The function to invoke. - - done: Function - Callback to invoke upon completion. - - thisArg: any (optional) - Execution context for the invoked function. - - Examples - -------- - > function predicate( i, clbk ) { clbk( null, i < 5 ); }; - > function fcn( i, next ) { - ... setTimeout( onTimeout, i ); - ... function onTimeout() { - ... next( null, 'boop'+i ); - ... } - ... }; - > function done( error, result ) { - ... if ( error ) { - ... throw error; - ... } - ... console.log( result ); - ... }; - > {{alias}}( predicate, fcn, done ) - boop: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4a543d9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,83 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 whileAsync = require( './index' ); - -const fcn = ( i: number, next: Function ): void => { - if ( i === void 0 ) { - throw new Error( '`i` is missing.' ); - } - next(); -}; - -const predicate = ( i: number, clbk: Function ): void => { - clbk( null, i < 5 ); -}; - -const done = ( error: Error | null ): void => { - if ( error ) { - throw error; - } -}; - - -// TESTS // - -// The function returns void... -{ - whileAsync( predicate, fcn, done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a predicate function... -{ - whileAsync( 2, fcn, done ); // $ExpectError - whileAsync( false, fcn, done ); // $ExpectError - whileAsync( true, fcn, done ); // $ExpectError - whileAsync( 'abc', fcn, done ); // $ExpectError - whileAsync( {}, fcn, done ); // $ExpectError - whileAsync( [], fcn, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function having a supported signature... -{ - whileAsync( predicate, 2, done ); // $ExpectError - whileAsync( predicate, false, done ); // $ExpectError - whileAsync( predicate, true, done ); // $ExpectError - whileAsync( predicate, 'abc', done ); // $ExpectError - whileAsync( predicate, {}, done ); // $ExpectError - whileAsync( predicate, [], done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a done callback argument which is not a function having a supported signature... -{ - whileAsync( predicate, fcn, 2 ); // $ExpectError - whileAsync( predicate, fcn, false ); // $ExpectError - whileAsync( predicate, fcn, true ); // $ExpectError - whileAsync( predicate, fcn, 'abc' ); // $ExpectError - whileAsync( predicate, fcn, {} ); // $ExpectError - whileAsync( predicate, fcn, [] ); // $ExpectError - whileAsync( predicate, fcn, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - whileAsync(); // $ExpectError - whileAsync( predicate ); // $ExpectError - whileAsync( predicate, fcn ); // $ExpectError - whileAsync( predicate, fcn, done, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a6af668..0000000 --- a/examples/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var repeatString = require( '@stdlib/string-repeat' ); -var whileAsync = require( './../lib' ); - -function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } -} - -function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, repeatString( 'beep', i+1 ) ); - } -} - -function done( error, result ) { - if ( error ) { - throw error; - } - console.log( result ); -} - -whileAsync( predicate, fcn, done ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..6f152ad --- /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-function@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function n(n,e,o,i){var s,l;if(!r(n))throw new TypeError(t("1Rr3c",n));if(!r(e))throw new TypeError(t("1Rr2H",e));if(!r(o))throw new TypeError(t("1Rr3N",o));function f(r,t){return r?o(r):t?e.call(i,l,h):(s.length&&s.unshift(null),void o.apply(null,s))}function h(r){var t;if(r)return o(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;8LA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a13bd4..0000000 --- a/lib/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Invoke a function while a test condition is true. -* -* @module @stdlib/utils-async-while -* -* @example -* var whileAsync = require( '@stdlib/utils-async-while' ); -* -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c1bab44..0000000 --- a/lib/main.js +++ /dev/null @@ -1,128 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Invokes a function while a test condition is true. -* -* @param {Function} predicate - function which indicates whether to continue invoking a function -* @param {Function} fcn - function to invoke -* @param {Callback} done - callback to invoke upon completion -* @param {*} [thisArg] - execution context for the invoked function -* @throws {TypeError} first argument must be a function -* @throws {TypeError} second argument must be a function -* @throws {TypeError} third argument must be a function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -function whileAsync( predicate, fcn, done, thisArg ) { - var args; - var idx; - if ( !isFunction( predicate ) ) { - throw new TypeError( format( '1Rr3c', predicate ) ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '1Rr2H', fcn ) ); - } - if ( !isFunction( done ) ) { - throw new TypeError( format( '1Rr3N', done ) ); - } - args = []; - idx = 0; - predicate( idx, onPredicate ); - - /** - * Callback invoked upon a predicate result. - * - * @private - * @param {(Error|null)} error - error object - * @param {boolean} result - predicate result - * @returns {void} - */ - function onPredicate( error, result ) { - if ( error ) { - return done( error ); - } - if ( result ) { - return fcn.call( thisArg, idx, next ); - } - if ( args.length ) { - args.unshift( null ); // error argument - } - done.apply( null, args ); - } - - /** - * Callback invoked upon completion of a provided function. - * - * @private - * @param {(Error|null)} error - error object - * @param {...*} results - function results - * @returns {void} - */ - function next( error ) { - var i; - if ( error ) { - return done( error ); - } - idx += 1; - - // Cache the most recent results... - if ( arguments.length > 1 ) { - args = new Array( arguments.length-1 ); - for ( i = 1; i < arguments.length; i++ ) { - args[ i-1 ] = arguments[ i ]; - } - } - // Run the test condition: - predicate( idx, onPredicate ); - } -} - - -// EXPORTS // - -module.exports = whileAsync; diff --git a/package.json b/package.json index a94b816..e1990aa 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Invoke a function while a test condition is true.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/math-base-assert-is-nan": "^0.2.2", - "@stdlib/random-base-randu": "^0.2.1", - "@stdlib/string-repeat": "^0.2.2", - "@stdlib/utils-noop": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..7a166a5 --- /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 78d0688..0000000 --- a/test/test.js +++ /dev/null @@ -1,328 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 whileAsync = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof whileAsync, 'function', 'main export is a function' ); - t.end(); -}); - -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() { - whileAsync( value, noop, 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() { - whileAsync( noop, value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a callback 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() { - whileAsync( noop, noop, value ); - }; - } -}); - -tape( 'while a test condition is true, the function invokes a provided function', function test( t ) { - var indices1 = [ 0, 1, 2, 3, 4, 5 ]; - var indices2 = [ 0, 1, 2, 3, 4 ]; - var j = -1; - var k = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices1[ j ], 'provides expected value' ); - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - k += 1; - t.strictEqual( i, indices2[ k ], 'provides expected value' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'while a test condition is true, the function invokes a provided function (always false)', function test( t ) { - var indices = [ 0 ]; - var j = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices[ j ], 'provides expected value' ); - clbk( null, false ); - } - - function fcn( i, next ) { - t.fail( 'should never be invoked' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx = { - 'count': 0 - }; - - whileAsync( predicate, fcn, done, ctx ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - this.count += 1; // eslint-disable-line no-invalid-this - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( ctx.count, 5, 'updates context' ); - t.end(); - } -}); - -tape( 'the function provides any results to a `done` callback', function test( t ) { - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, 'beep'+i, 'boop'+i, 'woot'+i ); - } - } - - function done( error, str1, str2, str3 ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( str1, 'beep4', 'returns expected value' ); - t.strictEqual( str2, 'boop4', 'returns expected value' ); - t.strictEqual( str3, 'woot4', 'returns expected value' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the predicate function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - if ( i === 1 ) { - return clbk( new Error( 'beep' ) ); - } - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 2, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the provided function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - if ( i === 2 ) { - return next( new Error( 'boop' ) ); - } - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 3, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'the function does not guarantee asynchronous execution', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - k = 1; - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - next(); - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( k, 0, 'releases the zalgo' ); - t.end(); - } -}); From 89f2d47fa1bdec3107eedef9e52d597386d504d2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 01:36:43 +0000 Subject: [PATCH 135/143] 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 1dafc2a..c1bab44 100644 --- a/lib/main.js +++ b/lib/main.js @@ -21,7 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -62,13 +62,13 @@ function whileAsync( predicate, fcn, done, thisArg ) { var args; var idx; if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '1Rr3c', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '1Rr2H', fcn ) ); } if ( !isFunction( done ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', done ) ); + throw new TypeError( format( '1Rr3N', done ) ); } args = []; idx = 0; diff --git a/package.json b/package.json index 77fbf5f..a94b816 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ }, "dependencies": { "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { From bb163385b6ec7d0f17e1614be085c3961d8efd5a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 02:31:49 +0000 Subject: [PATCH 136/143] Remove files --- index.d.ts | 127 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4974 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 163e8ba..0000000 --- a/index.d.ts +++ /dev/null @@ -1,127 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Callback function. -*/ -type Nullary = () => void; - -/** -* Callback function. -* -* @param error - encountered error or null -*/ -type Unary = ( error: Error | null ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Binary = ( error: Error | null, bool: boolean ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Callback = Nullary | Unary | Binary; - -/** -* Callback invoked upon completion. -*/ -type DoneNullary = () => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -*/ -type DoneUnary = ( error: Error | null ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneBinary = ( error: Error | null, ...args: Array ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneCallback = DoneNullary | DoneUnary | DoneBinary; - -/** -* Checks whether an element in a collection passes a test. -* -* @param i - iteration number (starting from one) -* @param clbk - a callback indicating whether to invoke `fcn` -*/ -type Predicate = ( i: number, clbk: Callback ) => void; - -/** -* Invoked function. -* -* @param i - iteration number (starting from zero) -* @param next - a callback which must be invoked before proceeding to the next iteration -*/ -type Fcn = ( i: number, next: Function ) => void; - -/** -* Invokes a function while a test condition is true. -* -* @param predicate - function which indicates whether to continue invoking a function -* @param fcn - function to invoke -* @param done - callback to invoke upon completion -* @param thisArg - execution context for the invoked function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -declare function whileAsync( predicate: Predicate, fcn: Fcn, done: DoneCallback, thisArg?: any ): void; - - -// EXPORTS // - -export = whileAsync; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 6f152ad..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-function@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function n(n,e,o,i){var s,l;if(!r(n))throw new TypeError(t("1Rr3c",n));if(!r(e))throw new TypeError(t("1Rr2H",e));if(!r(o))throw new TypeError(t("1Rr3N",o));function f(r,t){return r?o(r):t?e.call(i,l,h):(s.length&&s.unshift(null),void o.apply(null,s))}function h(r){var t;if(r)return o(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;8LA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 7a166a5..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From d17901c9631fd385a3c8e7a728ab43f06828c4eb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 02:32:03 +0000 Subject: [PATCH 137/143] 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 | 238 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 105 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 72 - docs/types/test.ts | 83 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 57 - lib/main.js | 128 - package.json | 57 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 328 -- 43 files changed, 4867 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 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 (100%) 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 00b7abc..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-11-01T01:20:11.414Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 0f8dec8..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/async/while) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 9633c26..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/async/while) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 0bdf3fd..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: '8 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' - # 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 + + ```
@@ -292,7 +283,7 @@ whileAsync( predicate, fcn, done ); ## 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]. @@ -357,13 +348,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until +[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until/tree/esm -[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while +[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while/tree/esm -[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until +[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until/tree/esm -[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while +[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while/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 7c83acf..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var whileAsync = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); - -bench( pkg+'::sync_predicate', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2c3ed87..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/async/while" -%% click B href "https://github.com/stdlib-js/utils-async-while/tree/main" -%% click C href "https://github.com/stdlib-js/utils-async-while/tree/production" -%% click D href "https://github.com/stdlib-js/utils-async-while/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-async-while/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-async-while/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/async/while -[production-url]: https://github.com/stdlib-js/utils-async-while/tree/production -[deno-url]: https://github.com/stdlib-js/utils-async-while/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-async-while/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-async-while/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-async-while/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-async-while/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-async-while/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 efdafdf..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import whileAsync from '../docs/types/index'; -export = whileAsync; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 159efee..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var v=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var m=v(function(p,g){ -var s=require('@stdlib/assert-is-function/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist');function c(t,r,e,o){var u,i;if(!s(t))throw new TypeError(l('1Rr3c',t));if(!s(r))throw new TypeError(l('1Rr2H',r));if(!s(e))throw new TypeError(l('1Rr3N',e));u=[],i=0,t(i,f);function f(a,n){if(a)return e(a);if(n)return r.call(o,i,h);u.length&&u.unshift(null),e.apply(null,u)}function h(a){var n;if(a)return e(a);if(i+=1,arguments.length>1)for(u=new Array(arguments.length-1),n=1;n 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = whileAsync;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Invoke a function while a test condition is true.\n*\n* @module @stdlib/utils-async-while\n*\n* @example\n* var whileAsync = require( '@stdlib/utils-async-while' );\n*\n* function predicate( i, clbk ) {\n* clbk( null, i < 5 );\n* }\n*\n* function fcn( i, next ) {\n* setTimeout( onTimeout, i );\n* function onTimeout() {\n* console.log( 'beep: %d', i );\n* next();\n* }\n* }\n*\n* function done( error ) {\n* if ( error ) {\n* throw error;\n* }\n* }\n*\n* whileAsync( predicate, fcn, done );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAS,QAAS,uBAAwB,EAqC9C,SAASC,EAAYC,EAAWC,EAAKC,EAAMC,EAAU,CACpD,IAAIC,EACAC,EACJ,GAAK,CAACR,EAAYG,CAAU,EAC3B,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAU,CAAE,EAE/G,GAAK,CAACH,EAAYI,CAAI,EACrB,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAI,CAAE,EAE1G,GAAK,CAACJ,EAAYK,CAAK,EACtB,MAAM,IAAI,UAAWJ,EAAQ,oEAAqEI,CAAK,CAAE,EAE1GE,EAAO,CAAC,EACRC,EAAM,EACNL,EAAWK,EAAKC,CAAY,EAU5B,SAASA,EAAaC,EAAOC,EAAS,CACrC,GAAKD,EACJ,OAAOL,EAAMK,CAAM,EAEpB,GAAKC,EACJ,OAAOP,EAAI,KAAME,EAASE,EAAKI,CAAK,EAEhCL,EAAK,QACTA,EAAK,QAAS,IAAK,EAEpBF,EAAK,MAAO,KAAME,CAAK,CACxB,CAUA,SAASK,EAAMF,EAAQ,CACtB,IAAIG,EACJ,GAAKH,EACJ,OAAOL,EAAMK,CAAM,EAKpB,GAHAF,GAAO,EAGF,UAAU,OAAS,EAEvB,IADAD,EAAO,IAAI,MAAO,UAAU,OAAO,CAAE,EAC/BM,EAAI,EAAGA,EAAI,UAAU,OAAQA,IAClCN,EAAMM,EAAE,CAAE,EAAI,UAAWA,CAAE,EAI7BV,EAAWK,EAAKC,CAAY,CAC7B,CACD,CAKAV,EAAO,QAAUG,IC5EjB,IAAIY,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "format", "whileAsync", "predicate", "fcn", "done", "thisArg", "args", "idx", "onPredicate", "error", "result", "next", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 960d0a1..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,72 +0,0 @@ - -{{alias}}( predicate, fcn, done[, thisArg] ) - Invokes a function while a test condition is true. - - The predicate function is provided two arguments: - - - i: iteration number (starting from zero). - - clbk: a callback indicating whether to invoke `fcn`. - - The `clbk` function accepts two arguments: - - - error: error argument. - - bool: test result. - - If the test result is truthy, the function invokes `fcn`; otherwise, the - function invokes the `done` callback. - - The function to invoke is provided two arguments: - - - i: iteration number (starting from zero). - - next: a callback which must be invoked before proceeding to the next - iteration. - - The first argument of the `next` callback is an `error` argument. If `fcn` - calls the `next` callback with a truthy `error` argument, the function - suspends execution and immediately calls the `done` callback for subsequent - `error` handling. - - The `done` callback is invoked with an `error` argument and any arguments - passed to the final `next` callback. - - Execution is *not* guaranteed to be asynchronous. To guarantee asynchrony, - wrap the `done` callback in a function which either executes at the end of - the current stack (e.g., `nextTick`) or during a subsequent turn of the - event loop (e.g., `setImmediate`, `setTimeout`). - - Parameters - ---------- - predicate: Function - The predicate function which indicates whether to continue invoking a - function. - - fcn: Function - The function to invoke. - - done: Function - Callback to invoke upon completion. - - thisArg: any (optional) - Execution context for the invoked function. - - Examples - -------- - > function predicate( i, clbk ) { clbk( null, i < 5 ); }; - > function fcn( i, next ) { - ... setTimeout( onTimeout, i ); - ... function onTimeout() { - ... next( null, 'boop'+i ); - ... } - ... }; - > function done( error, result ) { - ... if ( error ) { - ... throw error; - ... } - ... console.log( result ); - ... }; - > {{alias}}( predicate, fcn, done ) - boop: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4a543d9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,83 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 whileAsync = require( './index' ); - -const fcn = ( i: number, next: Function ): void => { - if ( i === void 0 ) { - throw new Error( '`i` is missing.' ); - } - next(); -}; - -const predicate = ( i: number, clbk: Function ): void => { - clbk( null, i < 5 ); -}; - -const done = ( error: Error | null ): void => { - if ( error ) { - throw error; - } -}; - - -// TESTS // - -// The function returns void... -{ - whileAsync( predicate, fcn, done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a predicate function... -{ - whileAsync( 2, fcn, done ); // $ExpectError - whileAsync( false, fcn, done ); // $ExpectError - whileAsync( true, fcn, done ); // $ExpectError - whileAsync( 'abc', fcn, done ); // $ExpectError - whileAsync( {}, fcn, done ); // $ExpectError - whileAsync( [], fcn, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function having a supported signature... -{ - whileAsync( predicate, 2, done ); // $ExpectError - whileAsync( predicate, false, done ); // $ExpectError - whileAsync( predicate, true, done ); // $ExpectError - whileAsync( predicate, 'abc', done ); // $ExpectError - whileAsync( predicate, {}, done ); // $ExpectError - whileAsync( predicate, [], done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a done callback argument which is not a function having a supported signature... -{ - whileAsync( predicate, fcn, 2 ); // $ExpectError - whileAsync( predicate, fcn, false ); // $ExpectError - whileAsync( predicate, fcn, true ); // $ExpectError - whileAsync( predicate, fcn, 'abc' ); // $ExpectError - whileAsync( predicate, fcn, {} ); // $ExpectError - whileAsync( predicate, fcn, [] ); // $ExpectError - whileAsync( predicate, fcn, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - whileAsync(); // $ExpectError - whileAsync( predicate ); // $ExpectError - whileAsync( predicate, fcn ); // $ExpectError - whileAsync( predicate, fcn, done, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a6af668..0000000 --- a/examples/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var repeatString = require( '@stdlib/string-repeat' ); -var whileAsync = require( './../lib' ); - -function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } -} - -function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, repeatString( 'beep', i+1 ) ); - } -} - -function done( error, result ) { - if ( error ) { - throw error; - } - console.log( result ); -} - -whileAsync( predicate, fcn, done ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..6f152ad --- /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-function@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function n(n,e,o,i){var s,l;if(!r(n))throw new TypeError(t("1Rr3c",n));if(!r(e))throw new TypeError(t("1Rr2H",e));if(!r(o))throw new TypeError(t("1Rr3N",o));function f(r,t){return r?o(r):t?e.call(i,l,h):(s.length&&s.unshift(null),void o.apply(null,s))}function h(r){var t;if(r)return o(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;8LA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a13bd4..0000000 --- a/lib/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Invoke a function while a test condition is true. -* -* @module @stdlib/utils-async-while -* -* @example -* var whileAsync = require( '@stdlib/utils-async-while' ); -* -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c1bab44..0000000 --- a/lib/main.js +++ /dev/null @@ -1,128 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Invokes a function while a test condition is true. -* -* @param {Function} predicate - function which indicates whether to continue invoking a function -* @param {Function} fcn - function to invoke -* @param {Callback} done - callback to invoke upon completion -* @param {*} [thisArg] - execution context for the invoked function -* @throws {TypeError} first argument must be a function -* @throws {TypeError} second argument must be a function -* @throws {TypeError} third argument must be a function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -function whileAsync( predicate, fcn, done, thisArg ) { - var args; - var idx; - if ( !isFunction( predicate ) ) { - throw new TypeError( format( '1Rr3c', predicate ) ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '1Rr2H', fcn ) ); - } - if ( !isFunction( done ) ) { - throw new TypeError( format( '1Rr3N', done ) ); - } - args = []; - idx = 0; - predicate( idx, onPredicate ); - - /** - * Callback invoked upon a predicate result. - * - * @private - * @param {(Error|null)} error - error object - * @param {boolean} result - predicate result - * @returns {void} - */ - function onPredicate( error, result ) { - if ( error ) { - return done( error ); - } - if ( result ) { - return fcn.call( thisArg, idx, next ); - } - if ( args.length ) { - args.unshift( null ); // error argument - } - done.apply( null, args ); - } - - /** - * Callback invoked upon completion of a provided function. - * - * @private - * @param {(Error|null)} error - error object - * @param {...*} results - function results - * @returns {void} - */ - function next( error ) { - var i; - if ( error ) { - return done( error ); - } - idx += 1; - - // Cache the most recent results... - if ( arguments.length > 1 ) { - args = new Array( arguments.length-1 ); - for ( i = 1; i < arguments.length; i++ ) { - args[ i-1 ] = arguments[ i ]; - } - } - // Run the test condition: - predicate( idx, onPredicate ); - } -} - - -// EXPORTS // - -module.exports = whileAsync; diff --git a/package.json b/package.json index a94b816..e1990aa 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Invoke a function while a test condition is true.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/math-base-assert-is-nan": "^0.2.2", - "@stdlib/random-base-randu": "^0.2.1", - "@stdlib/string-repeat": "^0.2.2", - "@stdlib/utils-noop": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..7a166a5 --- /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 78d0688..0000000 --- a/test/test.js +++ /dev/null @@ -1,328 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 whileAsync = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof whileAsync, 'function', 'main export is a function' ); - t.end(); -}); - -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() { - whileAsync( value, noop, 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() { - whileAsync( noop, value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a callback 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() { - whileAsync( noop, noop, value ); - }; - } -}); - -tape( 'while a test condition is true, the function invokes a provided function', function test( t ) { - var indices1 = [ 0, 1, 2, 3, 4, 5 ]; - var indices2 = [ 0, 1, 2, 3, 4 ]; - var j = -1; - var k = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices1[ j ], 'provides expected value' ); - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - k += 1; - t.strictEqual( i, indices2[ k ], 'provides expected value' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'while a test condition is true, the function invokes a provided function (always false)', function test( t ) { - var indices = [ 0 ]; - var j = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices[ j ], 'provides expected value' ); - clbk( null, false ); - } - - function fcn( i, next ) { - t.fail( 'should never be invoked' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx = { - 'count': 0 - }; - - whileAsync( predicate, fcn, done, ctx ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - this.count += 1; // eslint-disable-line no-invalid-this - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( ctx.count, 5, 'updates context' ); - t.end(); - } -}); - -tape( 'the function provides any results to a `done` callback', function test( t ) { - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, 'beep'+i, 'boop'+i, 'woot'+i ); - } - } - - function done( error, str1, str2, str3 ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( str1, 'beep4', 'returns expected value' ); - t.strictEqual( str2, 'boop4', 'returns expected value' ); - t.strictEqual( str3, 'woot4', 'returns expected value' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the predicate function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - if ( i === 1 ) { - return clbk( new Error( 'beep' ) ); - } - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 2, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the provided function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - if ( i === 2 ) { - return next( new Error( 'boop' ) ); - } - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 3, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'the function does not guarantee asynchronous execution', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - k = 1; - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - next(); - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( k, 0, 'releases the zalgo' ); - t.end(); - } -}); From 4286ec2d5a5b3953cccff0c169337ab32711ce5e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 01:43:52 +0000 Subject: [PATCH 138/143] 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 1dafc2a..c1bab44 100644 --- a/lib/main.js +++ b/lib/main.js @@ -21,7 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -62,13 +62,13 @@ function whileAsync( predicate, fcn, done, thisArg ) { var args; var idx; if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '1Rr3c', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '1Rr2H', fcn ) ); } if ( !isFunction( done ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', done ) ); + throw new TypeError( format( '1Rr3N', done ) ); } args = []; idx = 0; diff --git a/package.json b/package.json index 77fbf5f..a94b816 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ }, "dependencies": { "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { From 4055f8470f62912f2b24037536bcf42e149b659b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 02:46:49 +0000 Subject: [PATCH 139/143] Remove files --- index.d.ts | 127 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4974 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 163e8ba..0000000 --- a/index.d.ts +++ /dev/null @@ -1,127 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Callback function. -*/ -type Nullary = () => void; - -/** -* Callback function. -* -* @param error - encountered error or null -*/ -type Unary = ( error: Error | null ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Binary = ( error: Error | null, bool: boolean ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Callback = Nullary | Unary | Binary; - -/** -* Callback invoked upon completion. -*/ -type DoneNullary = () => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -*/ -type DoneUnary = ( error: Error | null ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneBinary = ( error: Error | null, ...args: Array ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneCallback = DoneNullary | DoneUnary | DoneBinary; - -/** -* Checks whether an element in a collection passes a test. -* -* @param i - iteration number (starting from one) -* @param clbk - a callback indicating whether to invoke `fcn` -*/ -type Predicate = ( i: number, clbk: Callback ) => void; - -/** -* Invoked function. -* -* @param i - iteration number (starting from zero) -* @param next - a callback which must be invoked before proceeding to the next iteration -*/ -type Fcn = ( i: number, next: Function ) => void; - -/** -* Invokes a function while a test condition is true. -* -* @param predicate - function which indicates whether to continue invoking a function -* @param fcn - function to invoke -* @param done - callback to invoke upon completion -* @param thisArg - execution context for the invoked function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -declare function whileAsync( predicate: Predicate, fcn: Fcn, done: DoneCallback, thisArg?: any ): void; - - -// EXPORTS // - -export = whileAsync; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 6f152ad..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-function@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function n(n,e,o,i){var s,l;if(!r(n))throw new TypeError(t("1Rr3c",n));if(!r(e))throw new TypeError(t("1Rr2H",e));if(!r(o))throw new TypeError(t("1Rr3N",o));function f(r,t){return r?o(r):t?e.call(i,l,h):(s.length&&s.unshift(null),void o.apply(null,s))}function h(r){var t;if(r)return o(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;8LA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 7a166a5..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 65aaa42d25eb0542cca3e37e3be6156e8d68f894 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 02:47:05 +0000 Subject: [PATCH 140/143] 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 | 238 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 105 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 72 - docs/types/test.ts | 83 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 57 - lib/main.js | 128 - package.json | 57 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 328 -- 44 files changed, 4867 insertions(+), 4528 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .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 (100%) 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 78de6a4..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-12-01T01:26:20.704Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 0f8dec8..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/async/while) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 9633c26..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/async/while) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 0bdf3fd..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: '8 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' - # 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 + + ```
@@ -292,7 +283,7 @@ whileAsync( predicate, fcn, done ); ## 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]. @@ -357,13 +348,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until +[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until/tree/esm -[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while +[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while/tree/esm -[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until +[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until/tree/esm -[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while +[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while/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 7c83acf..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var whileAsync = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); - -bench( pkg+'::sync_predicate', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2c3ed87..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/async/while" -%% click B href "https://github.com/stdlib-js/utils-async-while/tree/main" -%% click C href "https://github.com/stdlib-js/utils-async-while/tree/production" -%% click D href "https://github.com/stdlib-js/utils-async-while/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-async-while/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-async-while/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/async/while -[production-url]: https://github.com/stdlib-js/utils-async-while/tree/production -[deno-url]: https://github.com/stdlib-js/utils-async-while/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-async-while/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-async-while/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-async-while/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-async-while/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-async-while/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 efdafdf..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import whileAsync from '../docs/types/index'; -export = whileAsync; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 159efee..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var v=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var m=v(function(p,g){ -var s=require('@stdlib/assert-is-function/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist');function c(t,r,e,o){var u,i;if(!s(t))throw new TypeError(l('1Rr3c',t));if(!s(r))throw new TypeError(l('1Rr2H',r));if(!s(e))throw new TypeError(l('1Rr3N',e));u=[],i=0,t(i,f);function f(a,n){if(a)return e(a);if(n)return r.call(o,i,h);u.length&&u.unshift(null),e.apply(null,u)}function h(a){var n;if(a)return e(a);if(i+=1,arguments.length>1)for(u=new Array(arguments.length-1),n=1;n 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = whileAsync;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Invoke a function while a test condition is true.\n*\n* @module @stdlib/utils-async-while\n*\n* @example\n* var whileAsync = require( '@stdlib/utils-async-while' );\n*\n* function predicate( i, clbk ) {\n* clbk( null, i < 5 );\n* }\n*\n* function fcn( i, next ) {\n* setTimeout( onTimeout, i );\n* function onTimeout() {\n* console.log( 'beep: %d', i );\n* next();\n* }\n* }\n*\n* function done( error ) {\n* if ( error ) {\n* throw error;\n* }\n* }\n*\n* whileAsync( predicate, fcn, done );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAS,QAAS,uBAAwB,EAqC9C,SAASC,EAAYC,EAAWC,EAAKC,EAAMC,EAAU,CACpD,IAAIC,EACAC,EACJ,GAAK,CAACR,EAAYG,CAAU,EAC3B,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAU,CAAE,EAE/G,GAAK,CAACH,EAAYI,CAAI,EACrB,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAI,CAAE,EAE1G,GAAK,CAACJ,EAAYK,CAAK,EACtB,MAAM,IAAI,UAAWJ,EAAQ,oEAAqEI,CAAK,CAAE,EAE1GE,EAAO,CAAC,EACRC,EAAM,EACNL,EAAWK,EAAKC,CAAY,EAU5B,SAASA,EAAaC,EAAOC,EAAS,CACrC,GAAKD,EACJ,OAAOL,EAAMK,CAAM,EAEpB,GAAKC,EACJ,OAAOP,EAAI,KAAME,EAASE,EAAKI,CAAK,EAEhCL,EAAK,QACTA,EAAK,QAAS,IAAK,EAEpBF,EAAK,MAAO,KAAME,CAAK,CACxB,CAUA,SAASK,EAAMF,EAAQ,CACtB,IAAIG,EACJ,GAAKH,EACJ,OAAOL,EAAMK,CAAM,EAKpB,GAHAF,GAAO,EAGF,UAAU,OAAS,EAEvB,IADAD,EAAO,IAAI,MAAO,UAAU,OAAO,CAAE,EAC/BM,EAAI,EAAGA,EAAI,UAAU,OAAQA,IAClCN,EAAMM,EAAE,CAAE,EAAI,UAAWA,CAAE,EAI7BV,EAAWK,EAAKC,CAAY,CAC7B,CACD,CAKAV,EAAO,QAAUG,IC5EjB,IAAIY,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "format", "whileAsync", "predicate", "fcn", "done", "thisArg", "args", "idx", "onPredicate", "error", "result", "next", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 960d0a1..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,72 +0,0 @@ - -{{alias}}( predicate, fcn, done[, thisArg] ) - Invokes a function while a test condition is true. - - The predicate function is provided two arguments: - - - i: iteration number (starting from zero). - - clbk: a callback indicating whether to invoke `fcn`. - - The `clbk` function accepts two arguments: - - - error: error argument. - - bool: test result. - - If the test result is truthy, the function invokes `fcn`; otherwise, the - function invokes the `done` callback. - - The function to invoke is provided two arguments: - - - i: iteration number (starting from zero). - - next: a callback which must be invoked before proceeding to the next - iteration. - - The first argument of the `next` callback is an `error` argument. If `fcn` - calls the `next` callback with a truthy `error` argument, the function - suspends execution and immediately calls the `done` callback for subsequent - `error` handling. - - The `done` callback is invoked with an `error` argument and any arguments - passed to the final `next` callback. - - Execution is *not* guaranteed to be asynchronous. To guarantee asynchrony, - wrap the `done` callback in a function which either executes at the end of - the current stack (e.g., `nextTick`) or during a subsequent turn of the - event loop (e.g., `setImmediate`, `setTimeout`). - - Parameters - ---------- - predicate: Function - The predicate function which indicates whether to continue invoking a - function. - - fcn: Function - The function to invoke. - - done: Function - Callback to invoke upon completion. - - thisArg: any (optional) - Execution context for the invoked function. - - Examples - -------- - > function predicate( i, clbk ) { clbk( null, i < 5 ); }; - > function fcn( i, next ) { - ... setTimeout( onTimeout, i ); - ... function onTimeout() { - ... next( null, 'boop'+i ); - ... } - ... }; - > function done( error, result ) { - ... if ( error ) { - ... throw error; - ... } - ... console.log( result ); - ... }; - > {{alias}}( predicate, fcn, done ) - boop: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4a543d9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,83 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 whileAsync = require( './index' ); - -const fcn = ( i: number, next: Function ): void => { - if ( i === void 0 ) { - throw new Error( '`i` is missing.' ); - } - next(); -}; - -const predicate = ( i: number, clbk: Function ): void => { - clbk( null, i < 5 ); -}; - -const done = ( error: Error | null ): void => { - if ( error ) { - throw error; - } -}; - - -// TESTS // - -// The function returns void... -{ - whileAsync( predicate, fcn, done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a predicate function... -{ - whileAsync( 2, fcn, done ); // $ExpectError - whileAsync( false, fcn, done ); // $ExpectError - whileAsync( true, fcn, done ); // $ExpectError - whileAsync( 'abc', fcn, done ); // $ExpectError - whileAsync( {}, fcn, done ); // $ExpectError - whileAsync( [], fcn, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function having a supported signature... -{ - whileAsync( predicate, 2, done ); // $ExpectError - whileAsync( predicate, false, done ); // $ExpectError - whileAsync( predicate, true, done ); // $ExpectError - whileAsync( predicate, 'abc', done ); // $ExpectError - whileAsync( predicate, {}, done ); // $ExpectError - whileAsync( predicate, [], done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a done callback argument which is not a function having a supported signature... -{ - whileAsync( predicate, fcn, 2 ); // $ExpectError - whileAsync( predicate, fcn, false ); // $ExpectError - whileAsync( predicate, fcn, true ); // $ExpectError - whileAsync( predicate, fcn, 'abc' ); // $ExpectError - whileAsync( predicate, fcn, {} ); // $ExpectError - whileAsync( predicate, fcn, [] ); // $ExpectError - whileAsync( predicate, fcn, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - whileAsync(); // $ExpectError - whileAsync( predicate ); // $ExpectError - whileAsync( predicate, fcn ); // $ExpectError - whileAsync( predicate, fcn, done, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a6af668..0000000 --- a/examples/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var repeatString = require( '@stdlib/string-repeat' ); -var whileAsync = require( './../lib' ); - -function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } -} - -function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, repeatString( 'beep', i+1 ) ); - } -} - -function done( error, result ) { - if ( error ) { - throw error; - } - console.log( result ); -} - -whileAsync( predicate, fcn, done ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..6f152ad --- /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-function@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function n(n,e,o,i){var s,l;if(!r(n))throw new TypeError(t("1Rr3c",n));if(!r(e))throw new TypeError(t("1Rr2H",e));if(!r(o))throw new TypeError(t("1Rr3N",o));function f(r,t){return r?o(r):t?e.call(i,l,h):(s.length&&s.unshift(null),void o.apply(null,s))}function h(r){var t;if(r)return o(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;8LA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a13bd4..0000000 --- a/lib/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Invoke a function while a test condition is true. -* -* @module @stdlib/utils-async-while -* -* @example -* var whileAsync = require( '@stdlib/utils-async-while' ); -* -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c1bab44..0000000 --- a/lib/main.js +++ /dev/null @@ -1,128 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Invokes a function while a test condition is true. -* -* @param {Function} predicate - function which indicates whether to continue invoking a function -* @param {Function} fcn - function to invoke -* @param {Callback} done - callback to invoke upon completion -* @param {*} [thisArg] - execution context for the invoked function -* @throws {TypeError} first argument must be a function -* @throws {TypeError} second argument must be a function -* @throws {TypeError} third argument must be a function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -function whileAsync( predicate, fcn, done, thisArg ) { - var args; - var idx; - if ( !isFunction( predicate ) ) { - throw new TypeError( format( '1Rr3c', predicate ) ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '1Rr2H', fcn ) ); - } - if ( !isFunction( done ) ) { - throw new TypeError( format( '1Rr3N', done ) ); - } - args = []; - idx = 0; - predicate( idx, onPredicate ); - - /** - * Callback invoked upon a predicate result. - * - * @private - * @param {(Error|null)} error - error object - * @param {boolean} result - predicate result - * @returns {void} - */ - function onPredicate( error, result ) { - if ( error ) { - return done( error ); - } - if ( result ) { - return fcn.call( thisArg, idx, next ); - } - if ( args.length ) { - args.unshift( null ); // error argument - } - done.apply( null, args ); - } - - /** - * Callback invoked upon completion of a provided function. - * - * @private - * @param {(Error|null)} error - error object - * @param {...*} results - function results - * @returns {void} - */ - function next( error ) { - var i; - if ( error ) { - return done( error ); - } - idx += 1; - - // Cache the most recent results... - if ( arguments.length > 1 ) { - args = new Array( arguments.length-1 ); - for ( i = 1; i < arguments.length; i++ ) { - args[ i-1 ] = arguments[ i ]; - } - } - // Run the test condition: - predicate( idx, onPredicate ); - } -} - - -// EXPORTS // - -module.exports = whileAsync; diff --git a/package.json b/package.json index a94b816..e1990aa 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Invoke a function while a test condition is true.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/math-base-assert-is-nan": "^0.2.2", - "@stdlib/random-base-randu": "^0.2.1", - "@stdlib/string-repeat": "^0.2.2", - "@stdlib/utils-noop": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..7a166a5 --- /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 78d0688..0000000 --- a/test/test.js +++ /dev/null @@ -1,328 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 whileAsync = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof whileAsync, 'function', 'main export is a function' ); - t.end(); -}); - -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() { - whileAsync( value, noop, 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() { - whileAsync( noop, value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a callback 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() { - whileAsync( noop, noop, value ); - }; - } -}); - -tape( 'while a test condition is true, the function invokes a provided function', function test( t ) { - var indices1 = [ 0, 1, 2, 3, 4, 5 ]; - var indices2 = [ 0, 1, 2, 3, 4 ]; - var j = -1; - var k = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices1[ j ], 'provides expected value' ); - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - k += 1; - t.strictEqual( i, indices2[ k ], 'provides expected value' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'while a test condition is true, the function invokes a provided function (always false)', function test( t ) { - var indices = [ 0 ]; - var j = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices[ j ], 'provides expected value' ); - clbk( null, false ); - } - - function fcn( i, next ) { - t.fail( 'should never be invoked' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx = { - 'count': 0 - }; - - whileAsync( predicate, fcn, done, ctx ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - this.count += 1; // eslint-disable-line no-invalid-this - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( ctx.count, 5, 'updates context' ); - t.end(); - } -}); - -tape( 'the function provides any results to a `done` callback', function test( t ) { - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, 'beep'+i, 'boop'+i, 'woot'+i ); - } - } - - function done( error, str1, str2, str3 ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( str1, 'beep4', 'returns expected value' ); - t.strictEqual( str2, 'boop4', 'returns expected value' ); - t.strictEqual( str3, 'woot4', 'returns expected value' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the predicate function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - if ( i === 1 ) { - return clbk( new Error( 'beep' ) ); - } - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 2, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the provided function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - if ( i === 2 ) { - return next( new Error( 'boop' ) ); - } - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 3, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'the function does not guarantee asynchronous execution', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - k = 1; - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - next(); - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( k, 0, 'releases the zalgo' ); - t.end(); - } -}); From 6fc887f65287eade57578f3897c85cfcefbbb72b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 10 Mar 2025 00:52:01 +0000 Subject: [PATCH 141/143] 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 1dafc2a..c1bab44 100644 --- a/lib/main.js +++ b/lib/main.js @@ -21,7 +21,7 @@ // MODULES // var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -62,13 +62,13 @@ function whileAsync( predicate, fcn, done, thisArg ) { var args; var idx; if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', predicate ) ); + throw new TypeError( format( '1Rr3c', predicate ) ); } if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '1Rr2H', fcn ) ); } if ( !isFunction( done ) ) { - throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', done ) ); + throw new TypeError( format( '1Rr3N', done ) ); } args = []; idx = 0; diff --git a/package.json b/package.json index 77fbf5f..a94b816 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ }, "dependencies": { "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { From 128194d2aa872577998e2fb0209db9515b36dc3f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 10 Mar 2025 01:10:37 +0000 Subject: [PATCH 142/143] Remove files --- index.d.ts | 127 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4974 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 163e8ba..0000000 --- a/index.d.ts +++ /dev/null @@ -1,127 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 - -/** -* Callback function. -*/ -type Nullary = () => void; - -/** -* Callback function. -* -* @param error - encountered error or null -*/ -type Unary = ( error: Error | null ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Binary = ( error: Error | null, bool: boolean ) => void; - -/** -* Callback function. -* -* @param error - encountered error or null -* @param bool - test result -*/ -type Callback = Nullary | Unary | Binary; - -/** -* Callback invoked upon completion. -*/ -type DoneNullary = () => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -*/ -type DoneUnary = ( error: Error | null ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneBinary = ( error: Error | null, ...args: Array ) => void; - -/** -* Callback invoked upon completion. -* -* @param error - encountered error or null -* @param args - arguments passed to last `next` call -*/ -type DoneCallback = DoneNullary | DoneUnary | DoneBinary; - -/** -* Checks whether an element in a collection passes a test. -* -* @param i - iteration number (starting from one) -* @param clbk - a callback indicating whether to invoke `fcn` -*/ -type Predicate = ( i: number, clbk: Callback ) => void; - -/** -* Invoked function. -* -* @param i - iteration number (starting from zero) -* @param next - a callback which must be invoked before proceeding to the next iteration -*/ -type Fcn = ( i: number, next: Function ) => void; - -/** -* Invokes a function while a test condition is true. -* -* @param predicate - function which indicates whether to continue invoking a function -* @param fcn - function to invoke -* @param done - callback to invoke upon completion -* @param thisArg - execution context for the invoked function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -declare function whileAsync( predicate: Predicate, fcn: Fcn, done: DoneCallback, thisArg?: any ): void; - - -// EXPORTS // - -export = whileAsync; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 6f152ad..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-function@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function n(n,e,o,i){var s,l;if(!r(n))throw new TypeError(t("1Rr3c",n));if(!r(e))throw new TypeError(t("1Rr2H",e));if(!r(o))throw new TypeError(t("1Rr3N",o));function f(r,t){return r?o(r):t?e.call(i,l,h):(s.length&&s.unshift(null),void o.apply(null,s))}function h(r){var t;if(r)return o(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;8LA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 7a166a5..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 184bbc10f05a60bdd4ae21df0ae48ee52bbbed56 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 10 Mar 2025 01:11:12 +0000 Subject: [PATCH 143/143] 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 | 239 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 105 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 72 - docs/types/test.ts | 83 - examples/index.js | 45 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 57 - lib/main.js | 128 - package.json | 57 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 328 -- 44 files changed, 4867 insertions(+), 4532 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 (100%) 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 72c4a9d..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-03-10T00:45:39.468Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index b00ccce..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/async/while) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 9633c26..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/async/while) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 0bdf3fd..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: '8 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' - # 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 + + ```
@@ -292,7 +283,7 @@ whileAsync( predicate, fcn, done ); ## 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]. @@ -357,13 +348,13 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until +[@stdlib/utils/async/do-until]: https://github.com/stdlib-js/utils-async-do-until/tree/esm -[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while +[@stdlib/utils/async/do-while]: https://github.com/stdlib-js/utils-async-do-while/tree/esm -[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until +[@stdlib/utils/async/until]: https://github.com/stdlib-js/utils-async-until/tree/esm -[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while +[@stdlib/utils/while]: https://github.com/stdlib-js/utils-while/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 7c83acf..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,105 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var randu = require( '@stdlib/random-base-randu' ); -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pkg = require( './../package.json' ).name; -var whileAsync = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); - -bench( pkg+'::sync_predicate', function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next( error, result ) { - i += 1; - if ( error ) { - b.fail( 'should not return an error' ); - } - if ( i <= b.iterations ) { - return whileAsync( predicate, fcn, next ); - } - b.toc(); - if ( isnan( result ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, randu() ); - } - } -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 2c3ed87..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/async/while" -%% click B href "https://github.com/stdlib-js/utils-async-while/tree/main" -%% click C href "https://github.com/stdlib-js/utils-async-while/tree/production" -%% click D href "https://github.com/stdlib-js/utils-async-while/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-async-while/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-async-while/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/async/while -[production-url]: https://github.com/stdlib-js/utils-async-while/tree/production -[deno-url]: https://github.com/stdlib-js/utils-async-while/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-async-while/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-async-while/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-async-while/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-async-while/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-async-while/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 efdafdf..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import whileAsync from '../docs/types/index'; -export = whileAsync; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 159efee..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var v=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var m=v(function(p,g){ -var s=require('@stdlib/assert-is-function/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist');function c(t,r,e,o){var u,i;if(!s(t))throw new TypeError(l('1Rr3c',t));if(!s(r))throw new TypeError(l('1Rr2H',r));if(!s(e))throw new TypeError(l('1Rr3N',e));u=[],i=0,t(i,f);function f(a,n){if(a)return e(a);if(n)return r.call(o,i,h);u.length&&u.unshift(null),e.apply(null,u)}function h(a){var n;if(a)return e(a);if(i+=1,arguments.length>1)for(u=new Array(arguments.length-1),n=1;n 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = whileAsync;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Invoke a function while a test condition is true.\n*\n* @module @stdlib/utils-async-while\n*\n* @example\n* var whileAsync = require( '@stdlib/utils-async-while' );\n*\n* function predicate( i, clbk ) {\n* clbk( null, i < 5 );\n* }\n*\n* function fcn( i, next ) {\n* setTimeout( onTimeout, i );\n* function onTimeout() {\n* console.log( 'beep: %d', i );\n* next();\n* }\n* }\n*\n* function done( error ) {\n* if ( error ) {\n* throw error;\n* }\n* }\n*\n* whileAsync( predicate, fcn, done );\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,4BAA6B,EACnDC,EAAS,QAAS,uBAAwB,EAqC9C,SAASC,EAAYC,EAAWC,EAAKC,EAAMC,EAAU,CACpD,IAAIC,EACAC,EACJ,GAAK,CAACR,EAAYG,CAAU,EAC3B,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAU,CAAE,EAE/G,GAAK,CAACH,EAAYI,CAAI,EACrB,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAI,CAAE,EAE1G,GAAK,CAACJ,EAAYK,CAAK,EACtB,MAAM,IAAI,UAAWJ,EAAQ,oEAAqEI,CAAK,CAAE,EAE1GE,EAAO,CAAC,EACRC,EAAM,EACNL,EAAWK,EAAKC,CAAY,EAU5B,SAASA,EAAaC,EAAOC,EAAS,CACrC,GAAKD,EACJ,OAAOL,EAAMK,CAAM,EAEpB,GAAKC,EACJ,OAAOP,EAAI,KAAME,EAASE,EAAKI,CAAK,EAEhCL,EAAK,QACTA,EAAK,QAAS,IAAK,EAEpBF,EAAK,MAAO,KAAME,CAAK,CACxB,CAUA,SAASK,EAAMF,EAAQ,CACtB,IAAIG,EACJ,GAAKH,EACJ,OAAOL,EAAMK,CAAM,EAKpB,GAHAF,GAAO,EAGF,UAAU,OAAS,EAEvB,IADAD,EAAO,IAAI,MAAO,UAAU,OAAO,CAAE,EAC/BM,EAAI,EAAGA,EAAI,UAAU,OAAQA,IAClCN,EAAMM,EAAE,CAAE,EAAI,UAAWA,CAAE,EAI7BV,EAAWK,EAAKC,CAAY,CAC7B,CACD,CAKAV,EAAO,QAAUG,IC5EjB,IAAIY,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "format", "whileAsync", "predicate", "fcn", "done", "thisArg", "args", "idx", "onPredicate", "error", "result", "next", "i", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 960d0a1..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,72 +0,0 @@ - -{{alias}}( predicate, fcn, done[, thisArg] ) - Invokes a function while a test condition is true. - - The predicate function is provided two arguments: - - - i: iteration number (starting from zero). - - clbk: a callback indicating whether to invoke `fcn`. - - The `clbk` function accepts two arguments: - - - error: error argument. - - bool: test result. - - If the test result is truthy, the function invokes `fcn`; otherwise, the - function invokes the `done` callback. - - The function to invoke is provided two arguments: - - - i: iteration number (starting from zero). - - next: a callback which must be invoked before proceeding to the next - iteration. - - The first argument of the `next` callback is an `error` argument. If `fcn` - calls the `next` callback with a truthy `error` argument, the function - suspends execution and immediately calls the `done` callback for subsequent - `error` handling. - - The `done` callback is invoked with an `error` argument and any arguments - passed to the final `next` callback. - - Execution is *not* guaranteed to be asynchronous. To guarantee asynchrony, - wrap the `done` callback in a function which either executes at the end of - the current stack (e.g., `nextTick`) or during a subsequent turn of the - event loop (e.g., `setImmediate`, `setTimeout`). - - Parameters - ---------- - predicate: Function - The predicate function which indicates whether to continue invoking a - function. - - fcn: Function - The function to invoke. - - done: Function - Callback to invoke upon completion. - - thisArg: any (optional) - Execution context for the invoked function. - - Examples - -------- - > function predicate( i, clbk ) { clbk( null, i < 5 ); }; - > function fcn( i, next ) { - ... setTimeout( onTimeout, i ); - ... function onTimeout() { - ... next( null, 'boop'+i ); - ... } - ... }; - > function done( error, result ) { - ... if ( error ) { - ... throw error; - ... } - ... console.log( result ); - ... }; - > {{alias}}( predicate, fcn, done ) - boop: 4 - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4a543d9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,83 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 whileAsync = require( './index' ); - -const fcn = ( i: number, next: Function ): void => { - if ( i === void 0 ) { - throw new Error( '`i` is missing.' ); - } - next(); -}; - -const predicate = ( i: number, clbk: Function ): void => { - clbk( null, i < 5 ); -}; - -const done = ( error: Error | null ): void => { - if ( error ) { - throw error; - } -}; - - -// TESTS // - -// The function returns void... -{ - whileAsync( predicate, fcn, done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a predicate function... -{ - whileAsync( 2, fcn, done ); // $ExpectError - whileAsync( false, fcn, done ); // $ExpectError - whileAsync( true, fcn, done ); // $ExpectError - whileAsync( 'abc', fcn, done ); // $ExpectError - whileAsync( {}, fcn, done ); // $ExpectError - whileAsync( [], fcn, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function having a supported signature... -{ - whileAsync( predicate, 2, done ); // $ExpectError - whileAsync( predicate, false, done ); // $ExpectError - whileAsync( predicate, true, done ); // $ExpectError - whileAsync( predicate, 'abc', done ); // $ExpectError - whileAsync( predicate, {}, done ); // $ExpectError - whileAsync( predicate, [], done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a done callback argument which is not a function having a supported signature... -{ - whileAsync( predicate, fcn, 2 ); // $ExpectError - whileAsync( predicate, fcn, false ); // $ExpectError - whileAsync( predicate, fcn, true ); // $ExpectError - whileAsync( predicate, fcn, 'abc' ); // $ExpectError - whileAsync( predicate, fcn, {} ); // $ExpectError - whileAsync( predicate, fcn, [] ); // $ExpectError - whileAsync( predicate, fcn, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - whileAsync(); // $ExpectError - whileAsync( predicate ); // $ExpectError - whileAsync( predicate, fcn ); // $ExpectError - whileAsync( predicate, fcn, done, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index a6af668..0000000 --- a/examples/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var repeatString = require( '@stdlib/string-repeat' ); -var whileAsync = require( './../lib' ); - -function predicate( i, clbk ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - clbk( null, i < 5 ); - } -} - -function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, repeatString( 'beep', i+1 ) ); - } -} - -function done( error, result ) { - if ( error ) { - throw error; - } - console.log( result ); -} - -whileAsync( predicate, fcn, done ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 100% rename from docs/types/index.d.ts rename to index.d.ts diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..f0949ef --- /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-function@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function n(n,e,o,i){var s,l;if(!r(n))throw new TypeError(t("1Rr3c",n));if(!r(e))throw new TypeError(t("1Rr2H",e));if(!r(o))throw new TypeError(t("1Rr3N",o));function f(r,t){return r?o(r):t?e.call(i,l,h):(s.length&&s.unshift(null),void o.apply(null,s))}function h(r){var t;if(r)return o(r);if(l+=1,arguments.length>1)for(s=new Array(arguments.length-1),t=1;t 1 ) {\n\t\t\targs = new Array( arguments.length-1 );\n\t\t\tfor ( i = 1; i < arguments.length; i++ ) {\n\t\t\t\targs[ i-1 ] = arguments[ i ];\n\t\t\t}\n\t\t}\n\t\t// Run the test condition:\n\t\tpredicate( idx, onPredicate );\n\t}\n}\n\n\n// EXPORTS //\n\nexport default whileAsync;\n"],"names":["whileAsync","predicate","fcn","done","thisArg","args","idx","isFunction","TypeError","format","onPredicate","error","result","call","next","length","unshift","apply","i","arguments","Array"],"mappings":";;8LA4DA,SAASA,EAAYC,EAAWC,EAAKC,EAAMC,GAC1C,IAAIC,EACAC,EACJ,IAAMC,EAAYN,GACjB,MAAM,IAAIO,UAAWC,EAAQ,QAASR,IAEvC,IAAMM,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,IAAMK,EAAYJ,GACjB,MAAM,IAAIK,UAAWC,EAAQ,QAASN,IAcvC,SAASO,EAAaC,EAAOC,GAC5B,OAAKD,EACGR,EAAMQ,GAETC,EACGV,EAAIW,KAAMT,EAASE,EAAKQ,IAE3BT,EAAKU,QACTV,EAAKW,QAAS,WAEfb,EAAKc,MAAO,KAAMZ,GAClB,CAUD,SAASS,EAAMH,GACd,IAAIO,EACJ,GAAKP,EACJ,OAAOR,EAAMQ,GAKd,GAHAL,GAAO,EAGFa,UAAUJ,OAAS,EAEvB,IADAV,EAAO,IAAIe,MAAOD,UAAUJ,OAAO,GAC7BG,EAAI,EAAGA,EAAIC,UAAUJ,OAAQG,IAClCb,EAAMa,EAAE,GAAMC,UAAWD,GAI3BjB,EAAWK,EAAKI,EAChB,CAjDDL,EAAO,GAEPJ,EADAK,EAAM,EACUI,EAgDjB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 0a13bd4..0000000 --- a/lib/index.js +++ /dev/null @@ -1,57 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Invoke a function while a test condition is true. -* -* @module @stdlib/utils-async-while -* -* @example -* var whileAsync = require( '@stdlib/utils-async-while' ); -* -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index c1bab44..0000000 --- a/lib/main.js +++ /dev/null @@ -1,128 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isFunction = require( '@stdlib/assert-is-function' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Invokes a function while a test condition is true. -* -* @param {Function} predicate - function which indicates whether to continue invoking a function -* @param {Function} fcn - function to invoke -* @param {Callback} done - callback to invoke upon completion -* @param {*} [thisArg] - execution context for the invoked function -* @throws {TypeError} first argument must be a function -* @throws {TypeError} second argument must be a function -* @throws {TypeError} third argument must be a function -* -* @example -* function predicate( i, clbk ) { -* clbk( null, i < 5 ); -* } -* -* function fcn( i, next ) { -* setTimeout( onTimeout, i ); -* function onTimeout() { -* console.log( 'beep: %d', i ); -* next(); -* } -* } -* -* function done( error ) { -* if ( error ) { -* throw error; -* } -* } -* -* whileAsync( predicate, fcn, done ); -*/ -function whileAsync( predicate, fcn, done, thisArg ) { - var args; - var idx; - if ( !isFunction( predicate ) ) { - throw new TypeError( format( '1Rr3c', predicate ) ); - } - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '1Rr2H', fcn ) ); - } - if ( !isFunction( done ) ) { - throw new TypeError( format( '1Rr3N', done ) ); - } - args = []; - idx = 0; - predicate( idx, onPredicate ); - - /** - * Callback invoked upon a predicate result. - * - * @private - * @param {(Error|null)} error - error object - * @param {boolean} result - predicate result - * @returns {void} - */ - function onPredicate( error, result ) { - if ( error ) { - return done( error ); - } - if ( result ) { - return fcn.call( thisArg, idx, next ); - } - if ( args.length ) { - args.unshift( null ); // error argument - } - done.apply( null, args ); - } - - /** - * Callback invoked upon completion of a provided function. - * - * @private - * @param {(Error|null)} error - error object - * @param {...*} results - function results - * @returns {void} - */ - function next( error ) { - var i; - if ( error ) { - return done( error ); - } - idx += 1; - - // Cache the most recent results... - if ( arguments.length > 1 ) { - args = new Array( arguments.length-1 ); - for ( i = 1; i < arguments.length; i++ ) { - args[ i-1 ] = arguments[ i ]; - } - } - // Run the test condition: - predicate( idx, onPredicate ); - } -} - - -// EXPORTS // - -module.exports = whileAsync; diff --git a/package.json b/package.json index a94b816..e1990aa 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Invoke a function while a test condition is true.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,36 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/math-base-assert-is-nan": "^0.2.2", - "@stdlib/random-base-randu": "^0.2.1", - "@stdlib/string-repeat": "^0.2.2", - "@stdlib/utils-noop": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..7a166a5 --- /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 78d0688..0000000 --- a/test/test.js +++ /dev/null @@ -1,328 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 whileAsync = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof whileAsync, 'function', 'main export is a function' ); - t.end(); -}); - -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() { - whileAsync( value, noop, 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() { - whileAsync( noop, value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a callback 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() { - whileAsync( noop, noop, value ); - }; - } -}); - -tape( 'while a test condition is true, the function invokes a provided function', function test( t ) { - var indices1 = [ 0, 1, 2, 3, 4, 5 ]; - var indices2 = [ 0, 1, 2, 3, 4 ]; - var j = -1; - var k = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices1[ j ], 'provides expected value' ); - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - k += 1; - t.strictEqual( i, indices2[ k ], 'provides expected value' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'while a test condition is true, the function invokes a provided function (always false)', function test( t ) { - var indices = [ 0 ]; - var j = -1; - - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - j += 1; - t.strictEqual( i, indices[ j ], 'provides expected value' ); - clbk( null, false ); - } - - function fcn( i, next ) { - t.fail( 'should never be invoked' ); - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.end(); - } -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var ctx = { - 'count': 0 - }; - - whileAsync( predicate, fcn, done, ctx ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - this.count += 1; // eslint-disable-line no-invalid-this - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( ctx.count, 5, 'updates context' ); - t.end(); - } -}); - -tape( 'the function provides any results to a `done` callback', function test( t ) { - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next( null, 'beep'+i, 'boop'+i, 'woot'+i ); - } - } - - function done( error, str1, str2, str3 ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( str1, 'beep4', 'returns expected value' ); - t.strictEqual( str2, 'boop4', 'returns expected value' ); - t.strictEqual( str3, 'woot4', 'returns expected value' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the predicate function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - if ( i === 1 ) { - return clbk( new Error( 'beep' ) ); - } - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 2, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'if an error is encountered when invoking the provided function, the function suspends execution and immediately returns the `error` to the provided callback', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - - function predicate( i, clbk ) { - k += 1; - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - setTimeout( onTimeout, 0 ); - function onTimeout() { - if ( i === 2 ) { - return next( new Error( 'boop' ) ); - } - next(); - } - } - - function done( error ) { - if ( error ) { - t.pass( error.message ); - } else { - t.fail( 'should return an error' ); - } - t.strictEqual( k, 3, 'expected number of invocations' ); - t.end(); - } -}); - -tape( 'the function does not guarantee asynchronous execution', function test( t ) { - var k = 0; - whileAsync( predicate, fcn, done ); - k = 1; - - function predicate( i, clbk ) { - clbk( null, i < 5 ); - } - - function fcn( i, next ) { - next(); - } - - function done( error ) { - if ( error ) { - t.fail( error.message ); - } else { - t.ok( true, 'does not return an error' ); - } - t.strictEqual( k, 0, 'releases the zalgo' ); - t.end(); - } -});