From d9781890caa261932a66d091c0b0e370ef9a7a71 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Apr 2022 03:13:36 +0000 Subject: [PATCH 001/140] Auto-generated commit 43ca8c08137a89ed97316877c1d25be5025384e5 --- CONTRIBUTORS | 28 + LICENSE | 481 +++++++++ NOTICE | 1 + README.md | 314 ++++++ index.d.ts | 82 ++ index.mjs | 4 + index.mjs.map | 1 + package.json | 39 + stats.html | 2689 +++++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 3639 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..e462615 --- /dev/null +++ b/README.md @@ -0,0 +1,314 @@ + + +# curryRight + +[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] + +> Transform a function into a sequence of functions each accepting a single argument. + + + +
+ +
+ + + + + + + +
+ +## Usage + +```javascript +import curryRight from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-curry-right@esm/index.mjs'; +``` + +#### curryRight( fcn\[, arity]\[, thisArg] ) + +Transforms a function into a sequence of functions each accepting a single argument. + +```javascript +function add( x, y ) { + return x + y; +} + +var fcn = curryRight( add ); + +var sum = fcn( 2 )( 3 ); +// returns 5 +``` + +By default, `arity` is equal to `fcn.length`. For functions without explicit parameters, provide an `arity` argument. + +```javascript +function add() { + return arguments[ 0 ] + arguments[ 1 ]; +} + +var fcn = curryRight( add, 2 ); + +var sum = fcn( 2 )( 3 ); +// returns 5 +``` + +To specify the curried function execution context, provide a `thisArg` argument. + + + +```javascript +var obj = { + 'name': 'Ada', + 'greet': function greet( word1, word2 ) { + return word1 + ' ' + word2 + ', ' + this.name + '!'; + } +}; + +var fcn = curryRight( obj.greet, obj ); + +var str = fcn( 'there' )( 'Hello' ); +// returns 'Hello there, Ada!' +``` + +The function supports providing both an `arity` and execution context. + + + +```javascript +var obj = { + 'name': 'Ada', + 'greet': function greet() { + return arguments[ 0 ] + ' ' + arguments[ 1 ] + ', ' + this.name + '!'; + } +}; + +var fcn = curryRight( obj.greet, 2, obj ); + +var str = fcn( 'there' )( 'Hello' ); +// returns 'Hello there, Ada!' +``` + +
+ + + + + +
+ +## Notes + +- Until return value resolution, each invocation returns a new partially applied curry function. + + ```javascript + function add( x, y, z ) { + return x + y + z; + } + + var fcn = curryRight( add ); + + var s0 = fcn( 1 )( 2 )( 3 ); + // returns 6 + + s0 = fcn( -1 )( -2 )( -3 ); + // returns -6 + + s0 = fcn( 10 )( 20 )( 30 ); + // returns 60 + + // Return a partially applied curry function: + var f1 = fcn( 3 ); + + var s1 = f1( 4 )( 5 ); + // returns 12 + + s1 = f1( 6 )( 7 ); + // returns 16 + + s1 = f1( 8 )( 9 ); + // returns 20 + + // Return a partially applied curry function: + var f2 = fcn( 4 )( 5 ); + + var s2 = f2( 6 ); + // returns 15 + + s2 = f2( 70 ); + // returns 79 + + s2 = f2( 700 ); + // returns 709 + ``` + +- The difference between this function and [`curry`][@stdlib/utils/curry] is the order in which arguments are applied. This function applies arguments starting from the right. + +
+ + + + + +
+ +## 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..4a75788 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,82 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2019 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 2.0 + +/** +* Curry function. +* +* @param v - curried function parameter +* @returns partially applied curry function or curried function result +*/ +type Closure = ( v: any ) => any; + +/** +* Transforms a function into a sequence of functions each accepting a single argument. +* +* ## Notes +* +* - Until return value resolution, each invocation returns a new partially applied curry function. +* - This function applies arguments starting from the right. +* +* @param fcn - function to curry +* @param arity - number of parameters +* @param thisArg - evaluation context +* @throws `arity` must be a positive integer +* @returns curry function +* +* @example +* function add( x, y ) { +* return x + y; +* } +* +* var f = curryRight( add ); +* +* var sum = f( 2 )( 3 ); +* // returns 5 +*/ +declare function curryRight( fcn: Function, arity?: number, thisArg?: any ): Closure; // tslint-disable-line max-line-length + +/** +* Transforms a function into a sequence of functions each accepting a single argument. +* +* ## Notes +* +* - Until return value resolution, each invocation returns a new partially applied curry function. +* - This function applies arguments starting from the right. +* +* @param fcn - function to curry +* @param thisArg - evaluation context +* @returns curry function +* +* @example +* function add( x, y ) { +* return x + y; +* } +* +* var f = curryRight( add ); +* +* var sum = f( 2 )( 3 ); +* // returns 5 +*/ +declare function curryRight( fcn: Function, thisArg?: any ): Closure; + + +// EXPORTS // + +export = curryRight; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..ac3dc66 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@esm/index.mjs";var r=t,n=e.isPrimitive,s=i;var a=function(t,e,i){var a,l;if(!r(t))throw new TypeError(s("invalid argument. First argument must be a function. Value: `%s`.",t));if(arguments.length<2)l=t.length;else if(arguments.length>2){if(a=i,!n(l=e))throw new TypeError(s("invalid argument. Arity argument must be a positive integer. Value: `%s`.",l))}else n(e)?l=e:(l=t.length,a=e);return m([]);function m(e){return function(i){var r=e.slice();if(r.unshift(i),r.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) );\n\t\t}\n\t}\n\telse if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t}\n\telse {\n\t\tlen = fcn.length;\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = curryRight;\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* Transform a function into a sequence of functions each accepting a single argument.\n*\n* @module @stdlib/utils-curry-right\n*\n* @example\n* var curryRight = require( '@stdlib/utils-curry-right' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var f = curryRight( add );\n*\n* var sum = f( 2 )( 3 );\n* // returns 5\n*/\n\n// MODULES //\n\nvar curryRight = require( './curry_right.js' );\n\n\n// EXPORTS //\n\nmodule.exports = curryRight;\n"],"names":["isFunction","require$$0","isPositiveInteger","require$$1","isPrimitive","format","require$$2","lib","fcn","arity","thisArg","context","len","TypeError","arguments","length","createCurried","args","v","cargs","slice","unshift","apply"],"mappings":";;qQAsBA,IAAIA,EAAaC,EACbC,EAAoBC,EAAgDC,YACpEC,EAASC,EAiFb,IC5DAC,EDIA,SAAqBC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMZ,EAAYQ,GACjB,MAAM,IAAIK,UAAWR,EAAQ,oEAAqEG,IAEnG,GAAKM,UAAUC,OAAS,EACvBH,EAAMJ,EAAIO,YAEN,GAAKD,UAAUC,OAAS,GAG5B,GADAJ,EAAUD,GACJR,EAFNU,EAAMH,GAGL,MAAM,IAAII,UAAWR,EAAQ,4EAA6EO,SAGlGV,EAAmBO,GAC5BG,EAAMH,GAGNG,EAAMJ,EAAIO,OACVJ,EAAUF,GAEX,OAAOO,EAAe,IAStB,SAASA,EAAeC,GACvB,OASA,SAAkBC,GACjB,IAAIC,EAAQF,EAAKG,QAEjB,GADAD,EAAME,QAASH,GACVC,EAAMJ,OAASH,EACnB,OAAOI,EAAeG,GAEvB,OAAOX,EAAIc,MAAOX,EAASQ"} \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..22e0716 --- /dev/null +++ b/package.json @@ -0,0 +1,39 @@ +{ + "name": "@stdlib/utils-curry-right", + "version": "0.0.0", + "description": "Transform a function into a sequence of functions each accepting a single argument.", + "license": "Apache-2.0", + "type": "module", + "main": "./index.mjs", + "homepage": "https://stdlib.io", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/utils-curry-right.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "keywords": [ + "stdlib", + "stdutils", + "stdutil", + "utilities", + "utils", + "util", + "curry", + "curry-right", + "partial", + "partially", + "apply", + "function", + "fun", + "func", + "fcn", + "functional", + "transform" + ], + "funding": { + "type": "patreon", + "url": "https://www.patreon.com/athan" + } +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..0a91d84 --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + From 12cad19759fa43db5d2a6d9e76f8b6384e5bf355 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 30 Jun 2022 22:10:10 +0000 Subject: [PATCH 002/140] Transform error messages --- lib/curry_right.js | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/curry_right.js b/lib/curry_right.js index 8b18011..6793dfb 100644 --- a/lib/curry_right.js +++ b/lib/curry_right.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -51,7 +51,7 @@ function curryRight( fcn, arity, thisArg ) { var context; var len; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0j23p', fcn ) ); } if ( arguments.length < 2 ) { len = fcn.length; @@ -60,7 +60,7 @@ function curryRight( fcn, arity, thisArg ) { len = arity; context = thisArg; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) ); + throw new TypeError( format( '0j2Bi', len ) ); } } else if ( isPositiveInteger( arity ) ) { diff --git a/package.json b/package.json index f94e0f3..72bd40f 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-function": "^0.0.x", "@stdlib/assert-is-positive-integer": "^0.0.x", - "@stdlib/string-format": "^0.0.x" + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/bench": "^0.0.x", From a04f3dba017434713f1c81adb356c07f081d5ad0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 06:16:39 +0000 Subject: [PATCH 003/140] Remove files --- index.d.ts | 82 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2776 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 4a75788..0000000 --- a/index.d.ts +++ /dev/null @@ -1,82 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Curry function. -* -* @param v - curried function parameter -* @returns partially applied curry function or curried function result -*/ -type Closure = ( v: any ) => any; - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param arity - number of parameters -* @param thisArg - evaluation context -* @throws `arity` must be a positive integer -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight( fcn: Function, arity?: number, thisArg?: any ): Closure; // tslint-disable-line max-line-length - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param thisArg - evaluation context -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight( fcn: Function, thisArg?: any ): Closure; - - -// EXPORTS // - -export = curryRight; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index ac3dc66..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@esm/index.mjs";var r=t,n=e.isPrimitive,s=i;var a=function(t,e,i){var a,l;if(!r(t))throw new TypeError(s("invalid argument. First argument must be a function. Value: `%s`.",t));if(arguments.length<2)l=t.length;else if(arguments.length>2){if(a=i,!n(l=e))throw new TypeError(s("invalid argument. Arity argument must be a positive integer. Value: `%s`.",l))}else n(e)?l=e:(l=t.length,a=e);return m([]);function m(e){return function(i){var r=e.slice();if(r.unshift(i),r.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) );\n\t\t}\n\t}\n\telse if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t}\n\telse {\n\t\tlen = fcn.length;\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = curryRight;\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* Transform a function into a sequence of functions each accepting a single argument.\n*\n* @module @stdlib/utils-curry-right\n*\n* @example\n* var curryRight = require( '@stdlib/utils-curry-right' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var f = curryRight( add );\n*\n* var sum = f( 2 )( 3 );\n* // returns 5\n*/\n\n// MODULES //\n\nvar curryRight = require( './curry_right.js' );\n\n\n// EXPORTS //\n\nmodule.exports = curryRight;\n"],"names":["isFunction","require$$0","isPositiveInteger","require$$1","isPrimitive","format","require$$2","lib","fcn","arity","thisArg","context","len","TypeError","arguments","length","createCurried","args","v","cargs","slice","unshift","apply"],"mappings":";;qQAsBA,IAAIA,EAAaC,EACbC,EAAoBC,EAAgDC,YACpEC,EAASC,EAiFb,IC5DAC,EDIA,SAAqBC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMZ,EAAYQ,GACjB,MAAM,IAAIK,UAAWR,EAAQ,oEAAqEG,IAEnG,GAAKM,UAAUC,OAAS,EACvBH,EAAMJ,EAAIO,YAEN,GAAKD,UAAUC,OAAS,GAG5B,GADAJ,EAAUD,GACJR,EAFNU,EAAMH,GAGL,MAAM,IAAII,UAAWR,EAAQ,4EAA6EO,SAGlGV,EAAmBO,GAC5BG,EAAMH,GAGNG,EAAMJ,EAAIO,OACVJ,EAAUF,GAEX,OAAOO,EAAe,IAStB,SAASA,EAAeC,GACvB,OASA,SAAkBC,GACjB,IAAIC,EAAQF,EAAKG,QAEjB,GADAD,EAAME,QAASH,GACVC,EAAMJ,OAASH,EACnB,OAAOI,EAAeG,GAEvB,OAAOX,EAAIc,MAAOX,EAASQ"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 0a91d84..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 233d58dcbd1f0e300eb6bb935f72bafd3b7e27cb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 06:17:24 +0000 Subject: [PATCH 004/140] 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 | 39 +- benchmark/benchmark.js | 90 - branches.md | 53 - docs/repl.txt | 53 - docs/types/test.ts | 44 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/curry_right.js | 106 - lib/index.js | 46 - package.json | 55 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 251 -- 37 files changed, 2712 insertions(+), 3604 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/curry_right.js delete mode 100644 lib/index.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 512501b..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-06-30T21:56:08.340Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2b7fad0..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/curry-right) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 26300c3..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/curry-right) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -247,7 +240,7 @@ console.log( out ); ## 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]. @@ -309,11 +302,11 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry +[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry/tree/esm -[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry +[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry/tree/esm -[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right +[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index fbb976c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isFunction = require( '@stdlib/assert-is-function' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var curryRight = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = curryRight( pow ); - if ( typeof out !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( out ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::returned_function', function benchmark( b ) { - var fcn; - var out; - var i; - - fcn = curryRight( pow ); - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = fcn( randu() )( randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::direct', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = pow( randu(), randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 9ed19d3..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/curry-right" -click B href "https://github.com/stdlib-js/utils-curry-right/tree/main" -click C href "https://github.com/stdlib-js/utils-curry-right/tree/production" -click D href "https://github.com/stdlib-js/utils-curry-right/tree/esm" -click E href "https://github.com/stdlib-js/utils-curry-right/tree/deno" -click F href "https://github.com/stdlib-js/utils-curry-right/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/curry-right -[production-url]: https://github.com/stdlib-js/utils-curry-right/tree/production -[deno-url]: https://github.com/stdlib-js/utils-curry-right/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-curry-right/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-curry-right/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7271aed..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,53 +0,0 @@ - -{{alias}}( fcn[, arity][, thisArg] ) - Transforms a function into a sequence of functions each accepting a single - argument. - - Until return value resolution, each invocation returns a new partially - applied curry function. - - This function applies arguments starting from the right. - - Parameters - ---------- - fcn: Function - Function to curry. - - arity: integer (optional) - Number of parameters. Default: `fcn.length`. - - thisArg: any (optional) - Evaluation context. - - Returns - ------- - out: Function - Curry function. - - Examples - -------- - > function add( x, y ) { return x + y; }; - > var f = {{alias}}( add ); - > var sum = f( 2 )( 3 ) - 5 - - // Supply arity: - > function add() { return arguments[ 0 ] + arguments[ 1 ]; }; - > f = {{alias}}( add, 2 ); - > sum = f( 2 )( 3 ) - 5 - - // Provide function context: - > var obj = { - ... 'name': 'Ada', - ... 'greet': function greet( word1, word2 ) { - ... return word1 + ' ' + word2 + ', ' + this.name + '!' - ... } - ... }; - > f = {{alias}}( obj.greet, obj ); - > var str = f( 'there' )( 'Hello' ) - 'Hello there, Ada!' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a3b29c4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import curryRight = require( './index' ); - - -// TESTS // - -// The function returns a function... -{ - curryRight( ( x: number, y: number ): number => x + y ); // $ExpectType Closure - curryRight( ( x: number, y: number ): number => x + y, 2 ); // $ExpectType Closure - curryRight( ( x: number, y: number ): number => x + y, 2, {} ); // $ExpectType Closure -} - -// The compiler throws an error if the function is provided a first argument other than a function... -{ - curryRight( true ); // $ExpectError - curryRight( false ); // $ExpectError - curryRight( 5 ); // $ExpectError - curryRight( [] ); // $ExpectError - curryRight( {} ); // $ExpectError - curryRight( 'abc' ); // $ExpectError -} - -// The compiler throws an error if the function is provided more than three arguments... -{ - curryRight( ( x: number, y: number ): number => x + y, 2, {}, 4 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 76818ec..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 curryRight = require( './../lib' ); - -var fcn; -var out; -var i; - -function add( x, y, z, w, t, s ) { - return x + y + z + w + t + s; -} - -fcn = curryRight( add ); -out = fcn; -for ( i = 0; i < add.length; i++ ) { - out = out( i*10 ); -} -console.log( out ); 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..3bfdd1a --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";function s(s,n,i){var o,l;if(!t(s))throw new TypeError(r("0j23p",s));if(arguments.length<2)l=s.length;else if(arguments.length>2){if(o=i,!e(l=n))throw new TypeError(r("0j2Bi",l))}else e(n)?l=n:(l=s.length,o=n);return f([]);function f(t){return function(e){var r=t.slice();if(r.unshift(e),r.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '0j2Bi', len ) );\n\t\t}\n\t}\n\telse if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t}\n\telse {\n\t\tlen = fcn.length;\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","v","cargs","slice","unshift","apply"],"mappings":";;6RAiDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,EACvBL,EAAMJ,EAAIS,YAEN,GAAKD,UAAUC,OAAS,GAG5B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAG9BM,EAAmBT,GAC5BG,EAAMH,GAGNG,EAAMJ,EAAIS,OACVN,EAAUF,GAEX,OAAOU,EAAe,IAStB,SAASA,EAAeC,GACvB,OASA,SAAkBC,GACjB,IAAIC,EAAQF,EAAKG,QAEjB,GADAD,EAAME,QAASH,GACVC,EAAML,OAASL,EACnB,OAAOO,EAAeG,GAEvB,OAAOd,EAAIiB,MAAOd,EAASW"} \ No newline at end of file diff --git a/lib/curry_right.js b/lib/curry_right.js deleted file mode 100644 index 6793dfb..0000000 --- a/lib/curry_right.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* @param {Function} fcn - function to curry -* @param {PositiveInteger} [arity=fcn.length] - number of parameters -* @param {*} [thisArg] - evaluation context -* @throws {TypeError} first argument must be a function -* @throws {TypeError} `arity` argument must be a positive integer -* @returns {Function} curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -function curryRight( fcn, arity, thisArg ) { - var context; - var len; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0j23p', fcn ) ); - } - if ( arguments.length < 2 ) { - len = fcn.length; - } - else if ( arguments.length > 2 ) { - len = arity; - context = thisArg; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '0j2Bi', len ) ); - } - } - else if ( isPositiveInteger( arity ) ) { - len = arity; - } - else { - len = fcn.length; - context = arity; - } - return createCurried( [] ); - - /** - * Returns a curry function. - * - * @private - * @param {Array} args - arguments - * @returns {Function} curry function - */ - function createCurried( args ) { - return curried; - - /** - * Curry function. - * - * @private - * @param {*} v - curried function parameter - * @returns {(Function|*)} partially applied curry function or curried function result - */ - function curried( v ) { - var cargs = args.slice(); - cargs.unshift( v ); - if ( cargs.length < len ) { - return createCurried( cargs ); - } - return fcn.apply( context, cargs ); - } - } -} - - -// EXPORTS // - -module.exports = curryRight; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 56f7d52..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform a function into a sequence of functions each accepting a single argument. -* -* @module @stdlib/utils-curry-right -* -* @example -* var curryRight = require( '@stdlib/utils-curry-right' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ - -// MODULES // - -var curryRight = require( './curry_right.js' ); - - -// EXPORTS // - -module.exports = curryRight; diff --git a/package.json b/package.json index 72bd40f..3a2ccc5 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Transform a function into a sequence of functions each accepting a single argument.", "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,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-positive-integer": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/bench": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/random-base-randu": "^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..f284923 --- /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 3898169..0000000 --- a/test/test.js +++ /dev/null @@ -1,251 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var curryRight = require( './../lib' ); - - -// FUNCTIONS // - -function add( x, y, z ) { - return x + y + z; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof curryRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if provided an arity argument which is not a positive integer (3 args)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - 0, - -1, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( add, value, {} ); - }; - } -}); - -tape( 'the function returns a function', function test( t ) { - var fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function curries a function', function test( t) { - var fcn; - var f; - - fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'for each invocation where the invocation number is less than the arity, the curried function returns a new partially applied curry function', function test( t ) { - var sum; - var f0; - var f1; - var f2; - - // Initial curried function has no partially applied arguments... - f0 = curryRight( add ); - - sum = f0( 1 )( 2 )( 3 ); - t.strictEqual( sum, 6, 'returns 6' ); - - sum = f0( 1 )( 3 )( 5 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f0( 10 )( 20 )( 40 ); - t.strictEqual( sum, 70, 'returns 70' ); - - // If arity greater than 1, first invocation returns a curried function with one partially applied argument... - f1 = f0( 2 ); - - sum = f1( 3 )( 4 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f1( 10 )( 20 ); - t.strictEqual( sum, 32, 'returns 32' ); - - sum = f1( -1 )( -2 ); - t.strictEqual( sum, -1, 'returns -1' ); - - // If arity greater than 2, second invocation returns a curried function with two partially applied arguments... - f2 = f1( 3 ); - - sum = f2( 5 ); - t.strictEqual( sum, 10, 'returns 10' ); - - sum = f2( 6 ); - t.strictEqual( sum, 11, 'returns 11' ); - - sum = f2( 10 ); - t.strictEqual( sum, 15, 'returns 15' ); - - // And so on and so forth... - - t.end(); -}); - -tape( 'the function supports specifying a function arity', function test( t ) { - var fcn; - var f; - - function add() { - return arguments[ 0 ] + arguments[ 1 ] + arguments[ 2 ]; - } - - fcn = curryRight( add, 3 ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'the function supports specifying a function context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate( length, units, type, color ) { - return this.style+': '+length+units+' '+type+' '+color; - } - }; - - fcn = curryRight( context.generate, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); - -tape( 'the function supports specifying a function arity and context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate() { - return this.style+': '+arguments[0]+arguments[1]+' '+arguments[2]+' '+arguments[3]; - } - }; - - fcn = curryRight( context.generate, 4, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); From 92eca0ff55187c318176189d94518a564e85aea8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Jul 2022 20:05:56 +0000 Subject: [PATCH 005/140] Transform error messages --- lib/curry_right.js | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/curry_right.js b/lib/curry_right.js index 8b18011..6793dfb 100644 --- a/lib/curry_right.js +++ b/lib/curry_right.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -51,7 +51,7 @@ function curryRight( fcn, arity, thisArg ) { var context; var len; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0j23p', fcn ) ); } if ( arguments.length < 2 ) { len = fcn.length; @@ -60,7 +60,7 @@ function curryRight( fcn, arity, thisArg ) { len = arity; context = thisArg; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) ); + throw new TypeError( format( '0j2Bi', len ) ); } } else if ( isPositiveInteger( arity ) ) { diff --git a/package.json b/package.json index f94e0f3..72bd40f 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-function": "^0.0.x", "@stdlib/assert-is-positive-integer": "^0.0.x", - "@stdlib/string-format": "^0.0.x" + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/bench": "^0.0.x", From 78540b2b5b5b5d9c632ae80991911235534f5421 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Jul 2022 08:08:31 +0000 Subject: [PATCH 006/140] Remove files --- index.d.ts | 82 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2776 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 4a75788..0000000 --- a/index.d.ts +++ /dev/null @@ -1,82 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Curry function. -* -* @param v - curried function parameter -* @returns partially applied curry function or curried function result -*/ -type Closure = ( v: any ) => any; - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param arity - number of parameters -* @param thisArg - evaluation context -* @throws `arity` must be a positive integer -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight( fcn: Function, arity?: number, thisArg?: any ): Closure; // tslint-disable-line max-line-length - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param thisArg - evaluation context -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight( fcn: Function, thisArg?: any ): Closure; - - -// EXPORTS // - -export = curryRight; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 3bfdd1a..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";function s(s,n,i){var o,l;if(!t(s))throw new TypeError(r("0j23p",s));if(arguments.length<2)l=s.length;else if(arguments.length>2){if(o=i,!e(l=n))throw new TypeError(r("0j2Bi",l))}else e(n)?l=n:(l=s.length,o=n);return f([]);function f(t){return function(e){var r=t.slice();if(r.unshift(e),r.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '0j2Bi', len ) );\n\t\t}\n\t}\n\telse if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t}\n\telse {\n\t\tlen = fcn.length;\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","v","cargs","slice","unshift","apply"],"mappings":";;6RAiDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,EACvBL,EAAMJ,EAAIS,YAEN,GAAKD,UAAUC,OAAS,GAG5B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAG9BM,EAAmBT,GAC5BG,EAAMH,GAGNG,EAAMJ,EAAIS,OACVN,EAAUF,GAEX,OAAOU,EAAe,IAStB,SAASA,EAAeC,GACvB,OASA,SAAkBC,GACjB,IAAIC,EAAQF,EAAKG,QAEjB,GADAD,EAAME,QAASH,GACVC,EAAML,OAASL,EACnB,OAAOO,EAAeG,GAEvB,OAAOd,EAAIiB,MAAOd,EAASW"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index f284923..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From bf1a59448e9b76d237fc968e9838fd7b149fe2cd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Jul 2022 08:09:38 +0000 Subject: [PATCH 007/140] 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 | 39 +- benchmark/benchmark.js | 90 - branches.md | 53 - docs/repl.txt | 53 - docs/types/test.ts | 44 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/curry_right.js | 106 - lib/index.js | 46 - package.json | 55 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 251 -- 37 files changed, 2712 insertions(+), 3604 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/curry_right.js delete mode 100644 lib/index.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 8fd83f0..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-07-01T01:04:39.347Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2b7fad0..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/curry-right) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 26300c3..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/curry-right) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -247,7 +240,7 @@ console.log( out ); ## 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]. @@ -309,11 +302,11 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry +[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry/tree/esm -[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry +[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry/tree/esm -[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right +[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index fbb976c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isFunction = require( '@stdlib/assert-is-function' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var curryRight = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = curryRight( pow ); - if ( typeof out !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( out ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::returned_function', function benchmark( b ) { - var fcn; - var out; - var i; - - fcn = curryRight( pow ); - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = fcn( randu() )( randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::direct', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = pow( randu(), randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 9ed19d3..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/curry-right" -click B href "https://github.com/stdlib-js/utils-curry-right/tree/main" -click C href "https://github.com/stdlib-js/utils-curry-right/tree/production" -click D href "https://github.com/stdlib-js/utils-curry-right/tree/esm" -click E href "https://github.com/stdlib-js/utils-curry-right/tree/deno" -click F href "https://github.com/stdlib-js/utils-curry-right/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/curry-right -[production-url]: https://github.com/stdlib-js/utils-curry-right/tree/production -[deno-url]: https://github.com/stdlib-js/utils-curry-right/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-curry-right/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-curry-right/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7271aed..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,53 +0,0 @@ - -{{alias}}( fcn[, arity][, thisArg] ) - Transforms a function into a sequence of functions each accepting a single - argument. - - Until return value resolution, each invocation returns a new partially - applied curry function. - - This function applies arguments starting from the right. - - Parameters - ---------- - fcn: Function - Function to curry. - - arity: integer (optional) - Number of parameters. Default: `fcn.length`. - - thisArg: any (optional) - Evaluation context. - - Returns - ------- - out: Function - Curry function. - - Examples - -------- - > function add( x, y ) { return x + y; }; - > var f = {{alias}}( add ); - > var sum = f( 2 )( 3 ) - 5 - - // Supply arity: - > function add() { return arguments[ 0 ] + arguments[ 1 ]; }; - > f = {{alias}}( add, 2 ); - > sum = f( 2 )( 3 ) - 5 - - // Provide function context: - > var obj = { - ... 'name': 'Ada', - ... 'greet': function greet( word1, word2 ) { - ... return word1 + ' ' + word2 + ', ' + this.name + '!' - ... } - ... }; - > f = {{alias}}( obj.greet, obj ); - > var str = f( 'there' )( 'Hello' ) - 'Hello there, Ada!' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a3b29c4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import curryRight = require( './index' ); - - -// TESTS // - -// The function returns a function... -{ - curryRight( ( x: number, y: number ): number => x + y ); // $ExpectType Closure - curryRight( ( x: number, y: number ): number => x + y, 2 ); // $ExpectType Closure - curryRight( ( x: number, y: number ): number => x + y, 2, {} ); // $ExpectType Closure -} - -// The compiler throws an error if the function is provided a first argument other than a function... -{ - curryRight( true ); // $ExpectError - curryRight( false ); // $ExpectError - curryRight( 5 ); // $ExpectError - curryRight( [] ); // $ExpectError - curryRight( {} ); // $ExpectError - curryRight( 'abc' ); // $ExpectError -} - -// The compiler throws an error if the function is provided more than three arguments... -{ - curryRight( ( x: number, y: number ): number => x + y, 2, {}, 4 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 76818ec..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 curryRight = require( './../lib' ); - -var fcn; -var out; -var i; - -function add( x, y, z, w, t, s ) { - return x + y + z + w + t + s; -} - -fcn = curryRight( add ); -out = fcn; -for ( i = 0; i < add.length; i++ ) { - out = out( i*10 ); -} -console.log( out ); 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..3bfdd1a --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";function s(s,n,i){var o,l;if(!t(s))throw new TypeError(r("0j23p",s));if(arguments.length<2)l=s.length;else if(arguments.length>2){if(o=i,!e(l=n))throw new TypeError(r("0j2Bi",l))}else e(n)?l=n:(l=s.length,o=n);return f([]);function f(t){return function(e){var r=t.slice();if(r.unshift(e),r.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '0j2Bi', len ) );\n\t\t}\n\t}\n\telse if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t}\n\telse {\n\t\tlen = fcn.length;\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","v","cargs","slice","unshift","apply"],"mappings":";;6RAiDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,EACvBL,EAAMJ,EAAIS,YAEN,GAAKD,UAAUC,OAAS,GAG5B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAG9BM,EAAmBT,GAC5BG,EAAMH,GAGNG,EAAMJ,EAAIS,OACVN,EAAUF,GAEX,OAAOU,EAAe,IAStB,SAASA,EAAeC,GACvB,OASA,SAAkBC,GACjB,IAAIC,EAAQF,EAAKG,QAEjB,GADAD,EAAME,QAASH,GACVC,EAAML,OAASL,EACnB,OAAOO,EAAeG,GAEvB,OAAOd,EAAIiB,MAAOd,EAASW"} \ No newline at end of file diff --git a/lib/curry_right.js b/lib/curry_right.js deleted file mode 100644 index 6793dfb..0000000 --- a/lib/curry_right.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* @param {Function} fcn - function to curry -* @param {PositiveInteger} [arity=fcn.length] - number of parameters -* @param {*} [thisArg] - evaluation context -* @throws {TypeError} first argument must be a function -* @throws {TypeError} `arity` argument must be a positive integer -* @returns {Function} curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -function curryRight( fcn, arity, thisArg ) { - var context; - var len; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0j23p', fcn ) ); - } - if ( arguments.length < 2 ) { - len = fcn.length; - } - else if ( arguments.length > 2 ) { - len = arity; - context = thisArg; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '0j2Bi', len ) ); - } - } - else if ( isPositiveInteger( arity ) ) { - len = arity; - } - else { - len = fcn.length; - context = arity; - } - return createCurried( [] ); - - /** - * Returns a curry function. - * - * @private - * @param {Array} args - arguments - * @returns {Function} curry function - */ - function createCurried( args ) { - return curried; - - /** - * Curry function. - * - * @private - * @param {*} v - curried function parameter - * @returns {(Function|*)} partially applied curry function or curried function result - */ - function curried( v ) { - var cargs = args.slice(); - cargs.unshift( v ); - if ( cargs.length < len ) { - return createCurried( cargs ); - } - return fcn.apply( context, cargs ); - } - } -} - - -// EXPORTS // - -module.exports = curryRight; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 56f7d52..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform a function into a sequence of functions each accepting a single argument. -* -* @module @stdlib/utils-curry-right -* -* @example -* var curryRight = require( '@stdlib/utils-curry-right' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ - -// MODULES // - -var curryRight = require( './curry_right.js' ); - - -// EXPORTS // - -module.exports = curryRight; diff --git a/package.json b/package.json index 72bd40f..3a2ccc5 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Transform a function into a sequence of functions each accepting a single argument.", "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,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-positive-integer": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/bench": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/random-base-randu": "^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..5d03b1f --- /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 3898169..0000000 --- a/test/test.js +++ /dev/null @@ -1,251 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var curryRight = require( './../lib' ); - - -// FUNCTIONS // - -function add( x, y, z ) { - return x + y + z; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof curryRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if provided an arity argument which is not a positive integer (3 args)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - 0, - -1, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( add, value, {} ); - }; - } -}); - -tape( 'the function returns a function', function test( t ) { - var fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function curries a function', function test( t) { - var fcn; - var f; - - fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'for each invocation where the invocation number is less than the arity, the curried function returns a new partially applied curry function', function test( t ) { - var sum; - var f0; - var f1; - var f2; - - // Initial curried function has no partially applied arguments... - f0 = curryRight( add ); - - sum = f0( 1 )( 2 )( 3 ); - t.strictEqual( sum, 6, 'returns 6' ); - - sum = f0( 1 )( 3 )( 5 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f0( 10 )( 20 )( 40 ); - t.strictEqual( sum, 70, 'returns 70' ); - - // If arity greater than 1, first invocation returns a curried function with one partially applied argument... - f1 = f0( 2 ); - - sum = f1( 3 )( 4 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f1( 10 )( 20 ); - t.strictEqual( sum, 32, 'returns 32' ); - - sum = f1( -1 )( -2 ); - t.strictEqual( sum, -1, 'returns -1' ); - - // If arity greater than 2, second invocation returns a curried function with two partially applied arguments... - f2 = f1( 3 ); - - sum = f2( 5 ); - t.strictEqual( sum, 10, 'returns 10' ); - - sum = f2( 6 ); - t.strictEqual( sum, 11, 'returns 11' ); - - sum = f2( 10 ); - t.strictEqual( sum, 15, 'returns 15' ); - - // And so on and so forth... - - t.end(); -}); - -tape( 'the function supports specifying a function arity', function test( t ) { - var fcn; - var f; - - function add() { - return arguments[ 0 ] + arguments[ 1 ] + arguments[ 2 ]; - } - - fcn = curryRight( add, 3 ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'the function supports specifying a function context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate( length, units, type, color ) { - return this.style+': '+length+units+' '+type+' '+color; - } - }; - - fcn = curryRight( context.generate, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); - -tape( 'the function supports specifying a function arity and context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate() { - return this.style+': '+arguments[0]+arguments[1]+' '+arguments[2]+' '+arguments[3]; - } - }; - - fcn = curryRight( context.generate, 4, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); From 7a39d57212e2da6fbc8e4c2259e6c464bb2df08a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 5 Jul 2022 12:41:35 +0000 Subject: [PATCH 008/140] Transform error messages --- lib/curry_right.js | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/curry_right.js b/lib/curry_right.js index 8b18011..6793dfb 100644 --- a/lib/curry_right.js +++ b/lib/curry_right.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -51,7 +51,7 @@ function curryRight( fcn, arity, thisArg ) { var context; var len; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0j23p', fcn ) ); } if ( arguments.length < 2 ) { len = fcn.length; @@ -60,7 +60,7 @@ function curryRight( fcn, arity, thisArg ) { len = arity; context = thisArg; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) ); + throw new TypeError( format( '0j2Bi', len ) ); } } else if ( isPositiveInteger( arity ) ) { diff --git a/package.json b/package.json index f94e0f3..72bd40f 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-function": "^0.0.x", "@stdlib/assert-is-positive-integer": "^0.0.x", - "@stdlib/string-format": "^0.0.x" + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/bench": "^0.0.x", From ec4059ee0be84d6e8d72602c69cb76d3f874f65a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 5 Jul 2022 13:17:20 +0000 Subject: [PATCH 009/140] Remove files --- index.d.ts | 82 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2776 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 4a75788..0000000 --- a/index.d.ts +++ /dev/null @@ -1,82 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Curry function. -* -* @param v - curried function parameter -* @returns partially applied curry function or curried function result -*/ -type Closure = ( v: any ) => any; - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param arity - number of parameters -* @param thisArg - evaluation context -* @throws `arity` must be a positive integer -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight( fcn: Function, arity?: number, thisArg?: any ): Closure; // tslint-disable-line max-line-length - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param thisArg - evaluation context -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight( fcn: Function, thisArg?: any ): Closure; - - -// EXPORTS // - -export = curryRight; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 3bfdd1a..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";function s(s,n,i){var o,l;if(!t(s))throw new TypeError(r("0j23p",s));if(arguments.length<2)l=s.length;else if(arguments.length>2){if(o=i,!e(l=n))throw new TypeError(r("0j2Bi",l))}else e(n)?l=n:(l=s.length,o=n);return f([]);function f(t){return function(e){var r=t.slice();if(r.unshift(e),r.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '0j2Bi', len ) );\n\t\t}\n\t}\n\telse if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t}\n\telse {\n\t\tlen = fcn.length;\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","v","cargs","slice","unshift","apply"],"mappings":";;6RAiDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,EACvBL,EAAMJ,EAAIS,YAEN,GAAKD,UAAUC,OAAS,GAG5B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAG9BM,EAAmBT,GAC5BG,EAAMH,GAGNG,EAAMJ,EAAIS,OACVN,EAAUF,GAEX,OAAOU,EAAe,IAStB,SAASA,EAAeC,GACvB,OASA,SAAkBC,GACjB,IAAIC,EAAQF,EAAKG,QAEjB,GADAD,EAAME,QAASH,GACVC,EAAML,OAASL,EACnB,OAAOO,EAAeG,GAEvB,OAAOd,EAAIiB,MAAOd,EAASW"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 5d03b1f..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From dfdd976f24d8813fc20fbbe669c280a846badc49 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 5 Jul 2022 13:18:08 +0000 Subject: [PATCH 010/140] 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 | 39 +- benchmark/benchmark.js | 90 - branches.md | 53 - docs/repl.txt | 53 - docs/types/test.ts | 44 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/curry_right.js | 106 - lib/index.js | 46 - package.json | 55 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 251 -- 36 files changed, 2712 insertions(+), 3569 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/curry_right.js delete mode 100644 lib/index.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 2b7fad0..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/curry-right) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 26300c3..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/curry-right) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -247,7 +240,7 @@ console.log( out ); ## 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]. @@ -309,11 +302,11 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry +[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry/tree/esm -[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry +[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry/tree/esm -[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right +[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index fbb976c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isFunction = require( '@stdlib/assert-is-function' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var curryRight = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = curryRight( pow ); - if ( typeof out !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( out ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::returned_function', function benchmark( b ) { - var fcn; - var out; - var i; - - fcn = curryRight( pow ); - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = fcn( randu() )( randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::direct', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = pow( randu(), randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 9ed19d3..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/curry-right" -click B href "https://github.com/stdlib-js/utils-curry-right/tree/main" -click C href "https://github.com/stdlib-js/utils-curry-right/tree/production" -click D href "https://github.com/stdlib-js/utils-curry-right/tree/esm" -click E href "https://github.com/stdlib-js/utils-curry-right/tree/deno" -click F href "https://github.com/stdlib-js/utils-curry-right/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/curry-right -[production-url]: https://github.com/stdlib-js/utils-curry-right/tree/production -[deno-url]: https://github.com/stdlib-js/utils-curry-right/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-curry-right/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-curry-right/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7271aed..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,53 +0,0 @@ - -{{alias}}( fcn[, arity][, thisArg] ) - Transforms a function into a sequence of functions each accepting a single - argument. - - Until return value resolution, each invocation returns a new partially - applied curry function. - - This function applies arguments starting from the right. - - Parameters - ---------- - fcn: Function - Function to curry. - - arity: integer (optional) - Number of parameters. Default: `fcn.length`. - - thisArg: any (optional) - Evaluation context. - - Returns - ------- - out: Function - Curry function. - - Examples - -------- - > function add( x, y ) { return x + y; }; - > var f = {{alias}}( add ); - > var sum = f( 2 )( 3 ) - 5 - - // Supply arity: - > function add() { return arguments[ 0 ] + arguments[ 1 ]; }; - > f = {{alias}}( add, 2 ); - > sum = f( 2 )( 3 ) - 5 - - // Provide function context: - > var obj = { - ... 'name': 'Ada', - ... 'greet': function greet( word1, word2 ) { - ... return word1 + ' ' + word2 + ', ' + this.name + '!' - ... } - ... }; - > f = {{alias}}( obj.greet, obj ); - > var str = f( 'there' )( 'Hello' ) - 'Hello there, Ada!' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a3b29c4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import curryRight = require( './index' ); - - -// TESTS // - -// The function returns a function... -{ - curryRight( ( x: number, y: number ): number => x + y ); // $ExpectType Closure - curryRight( ( x: number, y: number ): number => x + y, 2 ); // $ExpectType Closure - curryRight( ( x: number, y: number ): number => x + y, 2, {} ); // $ExpectType Closure -} - -// The compiler throws an error if the function is provided a first argument other than a function... -{ - curryRight( true ); // $ExpectError - curryRight( false ); // $ExpectError - curryRight( 5 ); // $ExpectError - curryRight( [] ); // $ExpectError - curryRight( {} ); // $ExpectError - curryRight( 'abc' ); // $ExpectError -} - -// The compiler throws an error if the function is provided more than three arguments... -{ - curryRight( ( x: number, y: number ): number => x + y, 2, {}, 4 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 76818ec..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 curryRight = require( './../lib' ); - -var fcn; -var out; -var i; - -function add( x, y, z, w, t, s ) { - return x + y + z + w + t + s; -} - -fcn = curryRight( add ); -out = fcn; -for ( i = 0; i < add.length; i++ ) { - out = out( i*10 ); -} -console.log( out ); 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..3bfdd1a --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";function s(s,n,i){var o,l;if(!t(s))throw new TypeError(r("0j23p",s));if(arguments.length<2)l=s.length;else if(arguments.length>2){if(o=i,!e(l=n))throw new TypeError(r("0j2Bi",l))}else e(n)?l=n:(l=s.length,o=n);return f([]);function f(t){return function(e){var r=t.slice();if(r.unshift(e),r.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '0j2Bi', len ) );\n\t\t}\n\t}\n\telse if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t}\n\telse {\n\t\tlen = fcn.length;\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","v","cargs","slice","unshift","apply"],"mappings":";;6RAiDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,EACvBL,EAAMJ,EAAIS,YAEN,GAAKD,UAAUC,OAAS,GAG5B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAG9BM,EAAmBT,GAC5BG,EAAMH,GAGNG,EAAMJ,EAAIS,OACVN,EAAUF,GAEX,OAAOU,EAAe,IAStB,SAASA,EAAeC,GACvB,OASA,SAAkBC,GACjB,IAAIC,EAAQF,EAAKG,QAEjB,GADAD,EAAME,QAASH,GACVC,EAAML,OAASL,EACnB,OAAOO,EAAeG,GAEvB,OAAOd,EAAIiB,MAAOd,EAASW"} \ No newline at end of file diff --git a/lib/curry_right.js b/lib/curry_right.js deleted file mode 100644 index 6793dfb..0000000 --- a/lib/curry_right.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* @param {Function} fcn - function to curry -* @param {PositiveInteger} [arity=fcn.length] - number of parameters -* @param {*} [thisArg] - evaluation context -* @throws {TypeError} first argument must be a function -* @throws {TypeError} `arity` argument must be a positive integer -* @returns {Function} curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -function curryRight( fcn, arity, thisArg ) { - var context; - var len; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0j23p', fcn ) ); - } - if ( arguments.length < 2 ) { - len = fcn.length; - } - else if ( arguments.length > 2 ) { - len = arity; - context = thisArg; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '0j2Bi', len ) ); - } - } - else if ( isPositiveInteger( arity ) ) { - len = arity; - } - else { - len = fcn.length; - context = arity; - } - return createCurried( [] ); - - /** - * Returns a curry function. - * - * @private - * @param {Array} args - arguments - * @returns {Function} curry function - */ - function createCurried( args ) { - return curried; - - /** - * Curry function. - * - * @private - * @param {*} v - curried function parameter - * @returns {(Function|*)} partially applied curry function or curried function result - */ - function curried( v ) { - var cargs = args.slice(); - cargs.unshift( v ); - if ( cargs.length < len ) { - return createCurried( cargs ); - } - return fcn.apply( context, cargs ); - } - } -} - - -// EXPORTS // - -module.exports = curryRight; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 56f7d52..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform a function into a sequence of functions each accepting a single argument. -* -* @module @stdlib/utils-curry-right -* -* @example -* var curryRight = require( '@stdlib/utils-curry-right' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ - -// MODULES // - -var curryRight = require( './curry_right.js' ); - - -// EXPORTS // - -module.exports = curryRight; diff --git a/package.json b/package.json index 72bd40f..3a2ccc5 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Transform a function into a sequence of functions each accepting a single argument.", "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,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-positive-integer": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/bench": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/random-base-randu": "^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..17b4b97 --- /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 3898169..0000000 --- a/test/test.js +++ /dev/null @@ -1,251 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var curryRight = require( './../lib' ); - - -// FUNCTIONS // - -function add( x, y, z ) { - return x + y + z; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof curryRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if provided an arity argument which is not a positive integer (3 args)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - 0, - -1, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( add, value, {} ); - }; - } -}); - -tape( 'the function returns a function', function test( t ) { - var fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function curries a function', function test( t) { - var fcn; - var f; - - fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'for each invocation where the invocation number is less than the arity, the curried function returns a new partially applied curry function', function test( t ) { - var sum; - var f0; - var f1; - var f2; - - // Initial curried function has no partially applied arguments... - f0 = curryRight( add ); - - sum = f0( 1 )( 2 )( 3 ); - t.strictEqual( sum, 6, 'returns 6' ); - - sum = f0( 1 )( 3 )( 5 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f0( 10 )( 20 )( 40 ); - t.strictEqual( sum, 70, 'returns 70' ); - - // If arity greater than 1, first invocation returns a curried function with one partially applied argument... - f1 = f0( 2 ); - - sum = f1( 3 )( 4 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f1( 10 )( 20 ); - t.strictEqual( sum, 32, 'returns 32' ); - - sum = f1( -1 )( -2 ); - t.strictEqual( sum, -1, 'returns -1' ); - - // If arity greater than 2, second invocation returns a curried function with two partially applied arguments... - f2 = f1( 3 ); - - sum = f2( 5 ); - t.strictEqual( sum, 10, 'returns 10' ); - - sum = f2( 6 ); - t.strictEqual( sum, 11, 'returns 11' ); - - sum = f2( 10 ); - t.strictEqual( sum, 15, 'returns 15' ); - - // And so on and so forth... - - t.end(); -}); - -tape( 'the function supports specifying a function arity', function test( t ) { - var fcn; - var f; - - function add() { - return arguments[ 0 ] + arguments[ 1 ] + arguments[ 2 ]; - } - - fcn = curryRight( add, 3 ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'the function supports specifying a function context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate( length, units, type, color ) { - return this.style+': '+length+units+' '+type+' '+color; - } - }; - - fcn = curryRight( context.generate, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); - -tape( 'the function supports specifying a function arity and context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate() { - return this.style+': '+arguments[0]+arguments[1]+' '+arguments[2]+' '+arguments[3]; - } - }; - - fcn = curryRight( context.generate, 4, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); From ba5f84f01c1aca8f199be3b742ab86cce8275754 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 03:38:48 +0000 Subject: [PATCH 011/140] Transform error messages --- lib/curry_right.js | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/curry_right.js b/lib/curry_right.js index 8b18011..6793dfb 100644 --- a/lib/curry_right.js +++ b/lib/curry_right.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -51,7 +51,7 @@ function curryRight( fcn, arity, thisArg ) { var context; var len; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0j23p', fcn ) ); } if ( arguments.length < 2 ) { len = fcn.length; @@ -60,7 +60,7 @@ function curryRight( fcn, arity, thisArg ) { len = arity; context = thisArg; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) ); + throw new TypeError( format( '0j2Bi', len ) ); } } else if ( isPositiveInteger( arity ) ) { diff --git a/package.json b/package.json index f94e0f3..72bd40f 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-function": "^0.0.x", "@stdlib/assert-is-positive-integer": "^0.0.x", - "@stdlib/string-format": "^0.0.x" + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/bench": "^0.0.x", From 24741eef2a067b3e841f00fdc0c381a5ec00d3d1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 10:47:00 +0000 Subject: [PATCH 012/140] Remove files --- index.d.ts | 82 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2776 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 4a75788..0000000 --- a/index.d.ts +++ /dev/null @@ -1,82 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Curry function. -* -* @param v - curried function parameter -* @returns partially applied curry function or curried function result -*/ -type Closure = ( v: any ) => any; - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param arity - number of parameters -* @param thisArg - evaluation context -* @throws `arity` must be a positive integer -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight( fcn: Function, arity?: number, thisArg?: any ): Closure; // tslint-disable-line max-line-length - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param thisArg - evaluation context -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight( fcn: Function, thisArg?: any ): Closure; - - -// EXPORTS // - -export = curryRight; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 3bfdd1a..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";function s(s,n,i){var o,l;if(!t(s))throw new TypeError(r("0j23p",s));if(arguments.length<2)l=s.length;else if(arguments.length>2){if(o=i,!e(l=n))throw new TypeError(r("0j2Bi",l))}else e(n)?l=n:(l=s.length,o=n);return f([]);function f(t){return function(e){var r=t.slice();if(r.unshift(e),r.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '0j2Bi', len ) );\n\t\t}\n\t}\n\telse if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t}\n\telse {\n\t\tlen = fcn.length;\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","v","cargs","slice","unshift","apply"],"mappings":";;6RAiDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,EACvBL,EAAMJ,EAAIS,YAEN,GAAKD,UAAUC,OAAS,GAG5B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAG9BM,EAAmBT,GAC5BG,EAAMH,GAGNG,EAAMJ,EAAIS,OACVN,EAAUF,GAEX,OAAOU,EAAe,IAStB,SAASA,EAAeC,GACvB,OASA,SAAkBC,GACjB,IAAIC,EAAQF,EAAKG,QAEjB,GADAD,EAAME,QAASH,GACVC,EAAML,OAASL,EACnB,OAAOO,EAAeG,GAEvB,OAAOd,EAAIiB,MAAOd,EAASW"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 17b4b97..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From a2eb155856e964ce2f8dcf59d4abe0f705589a4a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Aug 2022 10:47:47 +0000 Subject: [PATCH 013/140] 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 | 39 +- benchmark/benchmark.js | 90 - branches.md | 53 - docs/repl.txt | 53 - docs/types/test.ts | 44 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/curry_right.js | 106 - lib/index.js | 46 - package.json | 55 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 251 -- 37 files changed, 2712 insertions(+), 3643 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/curry_right.js delete mode 100644 lib/index.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 eda24c6..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-08-01T01:07:53.917Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2b7fad0..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/curry-right) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 26300c3..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/curry-right) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -247,7 +240,7 @@ console.log( out ); ## 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]. @@ -309,11 +302,11 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry +[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry/tree/esm -[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry +[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry/tree/esm -[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right +[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index fbb976c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isFunction = require( '@stdlib/assert-is-function' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var curryRight = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = curryRight( pow ); - if ( typeof out !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( out ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::returned_function', function benchmark( b ) { - var fcn; - var out; - var i; - - fcn = curryRight( pow ); - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = fcn( randu() )( randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::direct', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = pow( randu(), randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 9ed19d3..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/curry-right" -click B href "https://github.com/stdlib-js/utils-curry-right/tree/main" -click C href "https://github.com/stdlib-js/utils-curry-right/tree/production" -click D href "https://github.com/stdlib-js/utils-curry-right/tree/esm" -click E href "https://github.com/stdlib-js/utils-curry-right/tree/deno" -click F href "https://github.com/stdlib-js/utils-curry-right/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/curry-right -[production-url]: https://github.com/stdlib-js/utils-curry-right/tree/production -[deno-url]: https://github.com/stdlib-js/utils-curry-right/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-curry-right/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-curry-right/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7271aed..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,53 +0,0 @@ - -{{alias}}( fcn[, arity][, thisArg] ) - Transforms a function into a sequence of functions each accepting a single - argument. - - Until return value resolution, each invocation returns a new partially - applied curry function. - - This function applies arguments starting from the right. - - Parameters - ---------- - fcn: Function - Function to curry. - - arity: integer (optional) - Number of parameters. Default: `fcn.length`. - - thisArg: any (optional) - Evaluation context. - - Returns - ------- - out: Function - Curry function. - - Examples - -------- - > function add( x, y ) { return x + y; }; - > var f = {{alias}}( add ); - > var sum = f( 2 )( 3 ) - 5 - - // Supply arity: - > function add() { return arguments[ 0 ] + arguments[ 1 ]; }; - > f = {{alias}}( add, 2 ); - > sum = f( 2 )( 3 ) - 5 - - // Provide function context: - > var obj = { - ... 'name': 'Ada', - ... 'greet': function greet( word1, word2 ) { - ... return word1 + ' ' + word2 + ', ' + this.name + '!' - ... } - ... }; - > f = {{alias}}( obj.greet, obj ); - > var str = f( 'there' )( 'Hello' ) - 'Hello there, Ada!' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a3b29c4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import curryRight = require( './index' ); - - -// TESTS // - -// The function returns a function... -{ - curryRight( ( x: number, y: number ): number => x + y ); // $ExpectType Closure - curryRight( ( x: number, y: number ): number => x + y, 2 ); // $ExpectType Closure - curryRight( ( x: number, y: number ): number => x + y, 2, {} ); // $ExpectType Closure -} - -// The compiler throws an error if the function is provided a first argument other than a function... -{ - curryRight( true ); // $ExpectError - curryRight( false ); // $ExpectError - curryRight( 5 ); // $ExpectError - curryRight( [] ); // $ExpectError - curryRight( {} ); // $ExpectError - curryRight( 'abc' ); // $ExpectError -} - -// The compiler throws an error if the function is provided more than three arguments... -{ - curryRight( ( x: number, y: number ): number => x + y, 2, {}, 4 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 76818ec..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 curryRight = require( './../lib' ); - -var fcn; -var out; -var i; - -function add( x, y, z, w, t, s ) { - return x + y + z + w + t + s; -} - -fcn = curryRight( add ); -out = fcn; -for ( i = 0; i < add.length; i++ ) { - out = out( i*10 ); -} -console.log( out ); 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..79a8631 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s,n,i){var o,l;if(!t(s))throw new TypeError(r("0j23p",s));if(arguments.length<2)l=s.length;else if(arguments.length>2){if(o=i,!e(l=n))throw new TypeError(r("0j2Bi",l))}else e(n)?l=n:(l=s.length,o=n);return f([]);function f(t){return function(e){var r=t.slice();if(r.unshift(e),r.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '0j2Bi', len ) );\n\t\t}\n\t}\n\telse if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t}\n\telse {\n\t\tlen = fcn.length;\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","v","cargs","slice","unshift","apply"],"mappings":";;oSAiDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,EACvBL,EAAMJ,EAAIS,YAEN,GAAKD,UAAUC,OAAS,GAG5B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAG9BM,EAAmBT,GAC5BG,EAAMH,GAGNG,EAAMJ,EAAIS,OACVN,EAAUF,GAEX,OAAOU,EAAe,IAStB,SAASA,EAAeC,GACvB,OASA,SAAkBC,GACjB,IAAIC,EAAQF,EAAKG,QAEjB,GADAD,EAAME,QAASH,GACVC,EAAML,OAASL,EACnB,OAAOO,EAAeG,GAEvB,OAAOd,EAAIiB,MAAOd,EAASW"} \ No newline at end of file diff --git a/lib/curry_right.js b/lib/curry_right.js deleted file mode 100644 index 6793dfb..0000000 --- a/lib/curry_right.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* @param {Function} fcn - function to curry -* @param {PositiveInteger} [arity=fcn.length] - number of parameters -* @param {*} [thisArg] - evaluation context -* @throws {TypeError} first argument must be a function -* @throws {TypeError} `arity` argument must be a positive integer -* @returns {Function} curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -function curryRight( fcn, arity, thisArg ) { - var context; - var len; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0j23p', fcn ) ); - } - if ( arguments.length < 2 ) { - len = fcn.length; - } - else if ( arguments.length > 2 ) { - len = arity; - context = thisArg; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '0j2Bi', len ) ); - } - } - else if ( isPositiveInteger( arity ) ) { - len = arity; - } - else { - len = fcn.length; - context = arity; - } - return createCurried( [] ); - - /** - * Returns a curry function. - * - * @private - * @param {Array} args - arguments - * @returns {Function} curry function - */ - function createCurried( args ) { - return curried; - - /** - * Curry function. - * - * @private - * @param {*} v - curried function parameter - * @returns {(Function|*)} partially applied curry function or curried function result - */ - function curried( v ) { - var cargs = args.slice(); - cargs.unshift( v ); - if ( cargs.length < len ) { - return createCurried( cargs ); - } - return fcn.apply( context, cargs ); - } - } -} - - -// EXPORTS // - -module.exports = curryRight; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 56f7d52..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform a function into a sequence of functions each accepting a single argument. -* -* @module @stdlib/utils-curry-right -* -* @example -* var curryRight = require( '@stdlib/utils-curry-right' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ - -// MODULES // - -var curryRight = require( './curry_right.js' ); - - -// EXPORTS // - -module.exports = curryRight; diff --git a/package.json b/package.json index 72bd40f..3a2ccc5 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Transform a function into a sequence of functions each accepting a single argument.", "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,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-positive-integer": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/bench": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/random-base-randu": "^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..7fb283b --- /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 3898169..0000000 --- a/test/test.js +++ /dev/null @@ -1,251 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var curryRight = require( './../lib' ); - - -// FUNCTIONS // - -function add( x, y, z ) { - return x + y + z; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof curryRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if provided an arity argument which is not a positive integer (3 args)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - 0, - -1, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( add, value, {} ); - }; - } -}); - -tape( 'the function returns a function', function test( t ) { - var fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function curries a function', function test( t) { - var fcn; - var f; - - fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'for each invocation where the invocation number is less than the arity, the curried function returns a new partially applied curry function', function test( t ) { - var sum; - var f0; - var f1; - var f2; - - // Initial curried function has no partially applied arguments... - f0 = curryRight( add ); - - sum = f0( 1 )( 2 )( 3 ); - t.strictEqual( sum, 6, 'returns 6' ); - - sum = f0( 1 )( 3 )( 5 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f0( 10 )( 20 )( 40 ); - t.strictEqual( sum, 70, 'returns 70' ); - - // If arity greater than 1, first invocation returns a curried function with one partially applied argument... - f1 = f0( 2 ); - - sum = f1( 3 )( 4 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f1( 10 )( 20 ); - t.strictEqual( sum, 32, 'returns 32' ); - - sum = f1( -1 )( -2 ); - t.strictEqual( sum, -1, 'returns -1' ); - - // If arity greater than 2, second invocation returns a curried function with two partially applied arguments... - f2 = f1( 3 ); - - sum = f2( 5 ); - t.strictEqual( sum, 10, 'returns 10' ); - - sum = f2( 6 ); - t.strictEqual( sum, 11, 'returns 11' ); - - sum = f2( 10 ); - t.strictEqual( sum, 15, 'returns 15' ); - - // And so on and so forth... - - t.end(); -}); - -tape( 'the function supports specifying a function arity', function test( t ) { - var fcn; - var f; - - function add() { - return arguments[ 0 ] + arguments[ 1 ] + arguments[ 2 ]; - } - - fcn = curryRight( add, 3 ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'the function supports specifying a function context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate( length, units, type, color ) { - return this.style+': '+length+units+' '+type+' '+color; - } - }; - - fcn = curryRight( context.generate, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); - -tape( 'the function supports specifying a function arity and context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate() { - return this.style+': '+arguments[0]+arguments[1]+' '+arguments[2]+' '+arguments[3]; - } - }; - - fcn = curryRight( context.generate, 4, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); From 8e75e93f3eb4989464fdb3706608b60196177f9e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 17 Aug 2022 21:15:36 +0000 Subject: [PATCH 014/140] Transform error messages --- lib/main.js | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/main.js b/lib/main.js index 8d7768e..6eebd6a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -52,7 +52,7 @@ function curryRight( fcn, arity, thisArg ) { var context; var len; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0j23p', fcn ) ); } if ( arguments.length < 2 ) { len = fcn.length; @@ -63,7 +63,7 @@ function curryRight( fcn, arity, thisArg ) { len = arity; context = thisArg; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) ); + throw new TypeError( format( '0j2Bi', len ) ); } } else if ( isPositiveInteger( arity ) ) { len = arity; diff --git a/package.json b/package.json index f94e0f3..72bd40f 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-function": "^0.0.x", "@stdlib/assert-is-positive-integer": "^0.0.x", - "@stdlib/string-format": "^0.0.x" + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/bench": "^0.0.x", From abea8448c8d1834692cff5bf818999f821acbef9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 17 Aug 2022 21:20:14 +0000 Subject: [PATCH 015/140] Remove files --- index.d.ts | 82 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2776 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 4a75788..0000000 --- a/index.d.ts +++ /dev/null @@ -1,82 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Curry function. -* -* @param v - curried function parameter -* @returns partially applied curry function or curried function result -*/ -type Closure = ( v: any ) => any; - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param arity - number of parameters -* @param thisArg - evaluation context -* @throws `arity` must be a positive integer -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight( fcn: Function, arity?: number, thisArg?: any ): Closure; // tslint-disable-line max-line-length - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param thisArg - evaluation context -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight( fcn: Function, thisArg?: any ): Closure; - - -// EXPORTS // - -export = curryRight; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 79a8631..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import t from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import{isPrimitive as e}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function s(s,n,i){var o,l;if(!t(s))throw new TypeError(r("0j23p",s));if(arguments.length<2)l=s.length;else if(arguments.length>2){if(o=i,!e(l=n))throw new TypeError(r("0j2Bi",l))}else e(n)?l=n:(l=s.length,o=n);return f([]);function f(t){return function(e){var r=t.slice();if(r.unshift(e),r.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '0j2Bi', len ) );\n\t\t}\n\t}\n\telse if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t}\n\telse {\n\t\tlen = fcn.length;\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","v","cargs","slice","unshift","apply"],"mappings":";;oSAiDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,EACvBL,EAAMJ,EAAIS,YAEN,GAAKD,UAAUC,OAAS,GAG5B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAG9BM,EAAmBT,GAC5BG,EAAMH,GAGNG,EAAMJ,EAAIS,OACVN,EAAUF,GAEX,OAAOU,EAAe,IAStB,SAASA,EAAeC,GACvB,OASA,SAAkBC,GACjB,IAAIC,EAAQF,EAAKG,QAEjB,GADAD,EAAME,QAASH,GACVC,EAAML,OAASL,EACnB,OAAOO,EAAeG,GAEvB,OAAOd,EAAIiB,MAAOd,EAASW"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 7fb283b..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From dc2d74e428974aa6c23293ae217225ef753c752d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 17 Aug 2022 21:21:08 +0000 Subject: [PATCH 016/140] 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 | 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 | 39 +- benchmark/benchmark.js | 90 - branches.md | 53 - docs/repl.txt | 53 - docs/types/test.ts | 44 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 110 - package.json | 55 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 291 --- 36 files changed, 2712 insertions(+), 3686 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 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 2b7fad0..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/curry-right) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 26300c3..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/curry-right) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -247,7 +240,7 @@ console.log( out ); ## 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]. @@ -309,11 +302,11 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry +[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry/tree/esm -[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry +[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry/tree/esm -[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right +[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index fbb976c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isFunction = require( '@stdlib/assert-is-function' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var curryRight = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = curryRight( pow ); - if ( typeof out !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( out ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::returned_function', function benchmark( b ) { - var fcn; - var out; - var i; - - fcn = curryRight( pow ); - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = fcn( randu() )( randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::direct', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = pow( randu(), randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 9ed19d3..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/curry-right" -click B href "https://github.com/stdlib-js/utils-curry-right/tree/main" -click C href "https://github.com/stdlib-js/utils-curry-right/tree/production" -click D href "https://github.com/stdlib-js/utils-curry-right/tree/esm" -click E href "https://github.com/stdlib-js/utils-curry-right/tree/deno" -click F href "https://github.com/stdlib-js/utils-curry-right/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/curry-right -[production-url]: https://github.com/stdlib-js/utils-curry-right/tree/production -[deno-url]: https://github.com/stdlib-js/utils-curry-right/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-curry-right/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-curry-right/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7271aed..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,53 +0,0 @@ - -{{alias}}( fcn[, arity][, thisArg] ) - Transforms a function into a sequence of functions each accepting a single - argument. - - Until return value resolution, each invocation returns a new partially - applied curry function. - - This function applies arguments starting from the right. - - Parameters - ---------- - fcn: Function - Function to curry. - - arity: integer (optional) - Number of parameters. Default: `fcn.length`. - - thisArg: any (optional) - Evaluation context. - - Returns - ------- - out: Function - Curry function. - - Examples - -------- - > function add( x, y ) { return x + y; }; - > var f = {{alias}}( add ); - > var sum = f( 2 )( 3 ) - 5 - - // Supply arity: - > function add() { return arguments[ 0 ] + arguments[ 1 ]; }; - > f = {{alias}}( add, 2 ); - > sum = f( 2 )( 3 ) - 5 - - // Provide function context: - > var obj = { - ... 'name': 'Ada', - ... 'greet': function greet( word1, word2 ) { - ... return word1 + ' ' + word2 + ', ' + this.name + '!' - ... } - ... }; - > f = {{alias}}( obj.greet, obj ); - > var str = f( 'there' )( 'Hello' ) - 'Hello there, Ada!' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a3b29c4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import curryRight = require( './index' ); - - -// TESTS // - -// The function returns a function... -{ - curryRight( ( x: number, y: number ): number => x + y ); // $ExpectType Closure - curryRight( ( x: number, y: number ): number => x + y, 2 ); // $ExpectType Closure - curryRight( ( x: number, y: number ): number => x + y, 2, {} ); // $ExpectType Closure -} - -// The compiler throws an error if the function is provided a first argument other than a function... -{ - curryRight( true ); // $ExpectError - curryRight( false ); // $ExpectError - curryRight( 5 ); // $ExpectError - curryRight( [] ); // $ExpectError - curryRight( {} ); // $ExpectError - curryRight( 'abc' ); // $ExpectError -} - -// The compiler throws an error if the function is provided more than three arguments... -{ - curryRight( ( x: number, y: number ): number => x + y, 2, {}, 4 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 76818ec..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 curryRight = require( './../lib' ); - -var fcn; -var out; -var i; - -function add( x, y, z, w, t, s ) { - return x + y + z + w + t + s; -} - -fcn = curryRight( add ); -out = fcn; -for ( i = 0; i < add.length; i++ ) { - out = out( i*10 ); -} -console.log( out ); 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..6fe3633 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,i,s){var o,a;if(!e(n))throw new TypeError(r("0j23p",n));if(arguments.length<2){if(a=n.length,!t(a))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",a))}else if(arguments.length>2){if(o=s,!t(a=i))throw new TypeError(r("0j2Bi",a))}else if(t(i))a=i;else{if(a=n.length,!t(a))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",a));o=i}return l([]);function l(e){return function(t){var r=e.slice();if(r.unshift(t),r.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '0j2Bi', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","v","cargs","slice","unshift","apply"],"mappings":";;oSAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,SAE3H,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAEjC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,IAEjID,EAAUF,EAEX,OAAOU,EAAe,IAStB,SAASA,EAAeC,GACvB,OASA,SAAkBC,GACjB,IAAIC,EAAQF,EAAKG,QAEjB,GADAD,EAAME,QAASH,GACVC,EAAML,OAASL,EACnB,OAAOO,EAAeG,GAEvB,OAAOd,EAAIiB,MAAOd,EAASW"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 7e7d2e8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform a function into a sequence of functions each accepting a single argument. -* -* @module @stdlib/utils-curry-right -* -* @example -* var curryRight = require( '@stdlib/utils-curry-right' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ - -// 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 6eebd6a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* @param {Function} fcn - function to curry -* @param {PositiveInteger} [arity=fcn.length] - number of parameters -* @param {*} [thisArg] - evaluation context -* @throws {TypeError} first argument must be a function -* @throws {TypeError} first argument must be a function having at least one parameter -* @throws {TypeError} `arity` argument must be a positive integer -* @returns {Function} curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -function curryRight( fcn, arity, thisArg ) { - var context; - var len; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0j23p', fcn ) ); - } - if ( arguments.length < 2 ) { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); - } - } else if ( arguments.length > 2 ) { - len = arity; - context = thisArg; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '0j2Bi', len ) ); - } - } else if ( isPositiveInteger( arity ) ) { - len = arity; - } else { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); - } - context = arity; - } - return createCurried( [] ); - - /** - * Returns a curry function. - * - * @private - * @param {Array} args - arguments - * @returns {Function} curry function - */ - function createCurried( args ) { - return curried; - - /** - * Curry function. - * - * @private - * @param {*} v - curried function parameter - * @returns {(Function|*)} partially applied curry function or curried function result - */ - function curried( v ) { - var cargs = args.slice(); - cargs.unshift( v ); - if ( cargs.length < len ) { - return createCurried( cargs ); - } - return fcn.apply( context, cargs ); - } - } -} - - -// EXPORTS // - -module.exports = curryRight; diff --git a/package.json b/package.json index 72bd40f..3a2ccc5 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Transform a function into a sequence of functions each accepting a single argument.", "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,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-positive-integer": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/bench": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/random-base-randu": "^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..219545a --- /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 b34eaef..0000000 --- a/test/test.js +++ /dev/null @@ -1,291 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var curryRight = require( './../lib' ); - - -// FUNCTIONS // - -function add( x, y, z ) { - return x + y + z; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof curryRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (1 arg)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (2 args; context)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an arity argument which is not a positive integer (3 args)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - 0, - -1, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( add, value, {} ); - }; - } -}); - -tape( 'the function returns a function', function test( t ) { - var fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function curries a function', function test( t) { - var fcn; - var f; - - fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'for each invocation where the invocation number is less than the arity, the curried function returns a new partially applied curry function', function test( t ) { - var sum; - var f0; - var f1; - var f2; - - // Initial curried function has no partially applied arguments... - f0 = curryRight( add ); - - sum = f0( 1 )( 2 )( 3 ); - t.strictEqual( sum, 6, 'returns 6' ); - - sum = f0( 1 )( 3 )( 5 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f0( 10 )( 20 )( 40 ); - t.strictEqual( sum, 70, 'returns 70' ); - - // If arity greater than 1, first invocation returns a curried function with one partially applied argument... - f1 = f0( 2 ); - - sum = f1( 3 )( 4 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f1( 10 )( 20 ); - t.strictEqual( sum, 32, 'returns 32' ); - - sum = f1( -1 )( -2 ); - t.strictEqual( sum, -1, 'returns -1' ); - - // If arity greater than 2, second invocation returns a curried function with two partially applied arguments... - f2 = f1( 3 ); - - sum = f2( 5 ); - t.strictEqual( sum, 10, 'returns 10' ); - - sum = f2( 6 ); - t.strictEqual( sum, 11, 'returns 11' ); - - sum = f2( 10 ); - t.strictEqual( sum, 15, 'returns 15' ); - - // And so on and so forth... - - t.end(); -}); - -tape( 'the function supports specifying a function arity', function test( t ) { - var fcn; - var f; - - function add() { - return arguments[ 0 ] + arguments[ 1 ] + arguments[ 2 ]; - } - - fcn = curryRight( add, 3 ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'the function supports specifying a function context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate( length, units, type, color ) { - return this.style+': '+length+units+' '+type+' '+color; - } - }; - - fcn = curryRight( context.generate, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); - -tape( 'the function supports specifying a function arity and context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate() { - return this.style+': '+arguments[0]+arguments[1]+' '+arguments[2]+' '+arguments[3]; - } - }; - - fcn = curryRight( context.generate, 4, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); From a552b75b194ea2d863dd17d7baa4529556d9b06e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 04:21:05 +0000 Subject: [PATCH 017/140] Transform error messages --- lib/main.js | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/main.js b/lib/main.js index 8d7768e..6eebd6a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -52,7 +52,7 @@ function curryRight( fcn, arity, thisArg ) { var context; var len; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0j23p', fcn ) ); } if ( arguments.length < 2 ) { len = fcn.length; @@ -63,7 +63,7 @@ function curryRight( fcn, arity, thisArg ) { len = arity; context = thisArg; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) ); + throw new TypeError( format( '0j2Bi', len ) ); } } else if ( isPositiveInteger( arity ) ) { len = arity; diff --git a/package.json b/package.json index f94e0f3..72bd40f 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-function": "^0.0.x", "@stdlib/assert-is-positive-integer": "^0.0.x", - "@stdlib/string-format": "^0.0.x" + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/bench": "^0.0.x", From 050b9ce2d8312ba25a380647ec2874338b2208d0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 12:23:32 +0000 Subject: [PATCH 018/140] Remove files --- index.d.ts | 82 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2776 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 689a825..0000000 --- a/index.d.ts +++ /dev/null @@ -1,82 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Curry function. -* -* @param v - curried function parameter -* @returns partially applied curry function or curried function result -*/ -type Closure = ( v: any ) => any; - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param arity - number of parameters -* @param thisArg - evaluation context -* @throws `arity` must be a positive integer -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight( fcn: Function, arity: number, thisArg?: any ): Closure; // tslint-disable-line max-line-length - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param thisArg - evaluation context -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight( fcn: Function, thisArg?: any ): Closure; - - -// EXPORTS // - -export = curryRight; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 6fe3633..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,i,s){var o,a;if(!e(n))throw new TypeError(r("0j23p",n));if(arguments.length<2){if(a=n.length,!t(a))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",a))}else if(arguments.length>2){if(o=s,!t(a=i))throw new TypeError(r("0j2Bi",a))}else if(t(i))a=i;else{if(a=n.length,!t(a))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",a));o=i}return l([]);function l(e){return function(t){var r=e.slice();if(r.unshift(t),r.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '0j2Bi', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","v","cargs","slice","unshift","apply"],"mappings":";;oSAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,SAE3H,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAEjC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,IAEjID,EAAUF,EAEX,OAAOU,EAAe,IAStB,SAASA,EAAeC,GACvB,OASA,SAAkBC,GACjB,IAAIC,EAAQF,EAAKG,QAEjB,GADAD,EAAME,QAASH,GACVC,EAAML,OAASL,EACnB,OAAOO,EAAeG,GAEvB,OAAOd,EAAIiB,MAAOd,EAASW"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 219545a..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From c15d637ddd1c363cf4b3d5bb7ca62f971284593a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Sep 2022 12:24:22 +0000 Subject: [PATCH 019/140] 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 | 39 +- benchmark/benchmark.js | 90 - branches.md | 53 - docs/repl.txt | 53 - docs/types/test.ts | 44 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 110 - package.json | 55 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 291 --- 37 files changed, 2712 insertions(+), 3703 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 96810cf..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-09-01T01:05:21.122Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2b7fad0..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/curry-right) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 26300c3..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/curry-right) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -247,7 +240,7 @@ console.log( out ); ## 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]. @@ -309,11 +302,11 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry +[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry/tree/esm -[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry +[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry/tree/esm -[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right +[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index fbb976c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isFunction = require( '@stdlib/assert-is-function' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var curryRight = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = curryRight( pow ); - if ( typeof out !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( out ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::returned_function', function benchmark( b ) { - var fcn; - var out; - var i; - - fcn = curryRight( pow ); - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = fcn( randu() )( randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::direct', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = pow( randu(), randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 9ed19d3..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/curry-right" -click B href "https://github.com/stdlib-js/utils-curry-right/tree/main" -click C href "https://github.com/stdlib-js/utils-curry-right/tree/production" -click D href "https://github.com/stdlib-js/utils-curry-right/tree/esm" -click E href "https://github.com/stdlib-js/utils-curry-right/tree/deno" -click F href "https://github.com/stdlib-js/utils-curry-right/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/curry-right -[production-url]: https://github.com/stdlib-js/utils-curry-right/tree/production -[deno-url]: https://github.com/stdlib-js/utils-curry-right/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-curry-right/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-curry-right/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7271aed..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,53 +0,0 @@ - -{{alias}}( fcn[, arity][, thisArg] ) - Transforms a function into a sequence of functions each accepting a single - argument. - - Until return value resolution, each invocation returns a new partially - applied curry function. - - This function applies arguments starting from the right. - - Parameters - ---------- - fcn: Function - Function to curry. - - arity: integer (optional) - Number of parameters. Default: `fcn.length`. - - thisArg: any (optional) - Evaluation context. - - Returns - ------- - out: Function - Curry function. - - Examples - -------- - > function add( x, y ) { return x + y; }; - > var f = {{alias}}( add ); - > var sum = f( 2 )( 3 ) - 5 - - // Supply arity: - > function add() { return arguments[ 0 ] + arguments[ 1 ]; }; - > f = {{alias}}( add, 2 ); - > sum = f( 2 )( 3 ) - 5 - - // Provide function context: - > var obj = { - ... 'name': 'Ada', - ... 'greet': function greet( word1, word2 ) { - ... return word1 + ' ' + word2 + ', ' + this.name + '!' - ... } - ... }; - > f = {{alias}}( obj.greet, obj ); - > var str = f( 'there' )( 'Hello' ) - 'Hello there, Ada!' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a3b29c4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import curryRight = require( './index' ); - - -// TESTS // - -// The function returns a function... -{ - curryRight( ( x: number, y: number ): number => x + y ); // $ExpectType Closure - curryRight( ( x: number, y: number ): number => x + y, 2 ); // $ExpectType Closure - curryRight( ( x: number, y: number ): number => x + y, 2, {} ); // $ExpectType Closure -} - -// The compiler throws an error if the function is provided a first argument other than a function... -{ - curryRight( true ); // $ExpectError - curryRight( false ); // $ExpectError - curryRight( 5 ); // $ExpectError - curryRight( [] ); // $ExpectError - curryRight( {} ); // $ExpectError - curryRight( 'abc' ); // $ExpectError -} - -// The compiler throws an error if the function is provided more than three arguments... -{ - curryRight( ( x: number, y: number ): number => x + y, 2, {}, 4 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 76818ec..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 curryRight = require( './../lib' ); - -var fcn; -var out; -var i; - -function add( x, y, z, w, t, s ) { - return x + y + z + w + t + s; -} - -fcn = curryRight( add ); -out = fcn; -for ( i = 0; i < add.length; i++ ) { - out = out( i*10 ); -} -console.log( out ); 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..6fe3633 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,i,s){var o,a;if(!e(n))throw new TypeError(r("0j23p",n));if(arguments.length<2){if(a=n.length,!t(a))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",a))}else if(arguments.length>2){if(o=s,!t(a=i))throw new TypeError(r("0j2Bi",a))}else if(t(i))a=i;else{if(a=n.length,!t(a))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",a));o=i}return l([]);function l(e){return function(t){var r=e.slice();if(r.unshift(t),r.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '0j2Bi', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","v","cargs","slice","unshift","apply"],"mappings":";;oSAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,SAE3H,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAEjC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,IAEjID,EAAUF,EAEX,OAAOU,EAAe,IAStB,SAASA,EAAeC,GACvB,OASA,SAAkBC,GACjB,IAAIC,EAAQF,EAAKG,QAEjB,GADAD,EAAME,QAASH,GACVC,EAAML,OAASL,EACnB,OAAOO,EAAeG,GAEvB,OAAOd,EAAIiB,MAAOd,EAASW"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 7e7d2e8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform a function into a sequence of functions each accepting a single argument. -* -* @module @stdlib/utils-curry-right -* -* @example -* var curryRight = require( '@stdlib/utils-curry-right' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ - -// 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 6eebd6a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* @param {Function} fcn - function to curry -* @param {PositiveInteger} [arity=fcn.length] - number of parameters -* @param {*} [thisArg] - evaluation context -* @throws {TypeError} first argument must be a function -* @throws {TypeError} first argument must be a function having at least one parameter -* @throws {TypeError} `arity` argument must be a positive integer -* @returns {Function} curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -function curryRight( fcn, arity, thisArg ) { - var context; - var len; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0j23p', fcn ) ); - } - if ( arguments.length < 2 ) { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); - } - } else if ( arguments.length > 2 ) { - len = arity; - context = thisArg; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '0j2Bi', len ) ); - } - } else if ( isPositiveInteger( arity ) ) { - len = arity; - } else { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); - } - context = arity; - } - return createCurried( [] ); - - /** - * Returns a curry function. - * - * @private - * @param {Array} args - arguments - * @returns {Function} curry function - */ - function createCurried( args ) { - return curried; - - /** - * Curry function. - * - * @private - * @param {*} v - curried function parameter - * @returns {(Function|*)} partially applied curry function or curried function result - */ - function curried( v ) { - var cargs = args.slice(); - cargs.unshift( v ); - if ( cargs.length < len ) { - return createCurried( cargs ); - } - return fcn.apply( context, cargs ); - } - } -} - - -// EXPORTS // - -module.exports = curryRight; diff --git a/package.json b/package.json index 72bd40f..3a2ccc5 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Transform a function into a sequence of functions each accepting a single argument.", "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,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-positive-integer": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/bench": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/random-base-randu": "^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..bb9b3ad --- /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 b34eaef..0000000 --- a/test/test.js +++ /dev/null @@ -1,291 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var curryRight = require( './../lib' ); - - -// FUNCTIONS // - -function add( x, y, z ) { - return x + y + z; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof curryRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (1 arg)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (2 args; context)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an arity argument which is not a positive integer (3 args)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - 0, - -1, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( add, value, {} ); - }; - } -}); - -tape( 'the function returns a function', function test( t ) { - var fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function curries a function', function test( t) { - var fcn; - var f; - - fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'for each invocation where the invocation number is less than the arity, the curried function returns a new partially applied curry function', function test( t ) { - var sum; - var f0; - var f1; - var f2; - - // Initial curried function has no partially applied arguments... - f0 = curryRight( add ); - - sum = f0( 1 )( 2 )( 3 ); - t.strictEqual( sum, 6, 'returns 6' ); - - sum = f0( 1 )( 3 )( 5 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f0( 10 )( 20 )( 40 ); - t.strictEqual( sum, 70, 'returns 70' ); - - // If arity greater than 1, first invocation returns a curried function with one partially applied argument... - f1 = f0( 2 ); - - sum = f1( 3 )( 4 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f1( 10 )( 20 ); - t.strictEqual( sum, 32, 'returns 32' ); - - sum = f1( -1 )( -2 ); - t.strictEqual( sum, -1, 'returns -1' ); - - // If arity greater than 2, second invocation returns a curried function with two partially applied arguments... - f2 = f1( 3 ); - - sum = f2( 5 ); - t.strictEqual( sum, 10, 'returns 10' ); - - sum = f2( 6 ); - t.strictEqual( sum, 11, 'returns 11' ); - - sum = f2( 10 ); - t.strictEqual( sum, 15, 'returns 15' ); - - // And so on and so forth... - - t.end(); -}); - -tape( 'the function supports specifying a function arity', function test( t ) { - var fcn; - var f; - - function add() { - return arguments[ 0 ] + arguments[ 1 ] + arguments[ 2 ]; - } - - fcn = curryRight( add, 3 ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'the function supports specifying a function context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate( length, units, type, color ) { - return this.style+': '+length+units+' '+type+' '+color; - } - }; - - fcn = curryRight( context.generate, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); - -tape( 'the function supports specifying a function arity and context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate() { - return this.style+': '+arguments[0]+arguments[1]+' '+arguments[2]+' '+arguments[3]; - } - }; - - fcn = curryRight( context.generate, 4, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); From 2a0b7d651f9a1d72ece15d0db1b5a6e9c36ec10a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Oct 2022 04:29:34 +0000 Subject: [PATCH 020/140] Transform error messages --- lib/main.js | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/main.js b/lib/main.js index 8d7768e..6eebd6a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -52,7 +52,7 @@ function curryRight( fcn, arity, thisArg ) { var context; var len; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0j23p', fcn ) ); } if ( arguments.length < 2 ) { len = fcn.length; @@ -63,7 +63,7 @@ function curryRight( fcn, arity, thisArg ) { len = arity; context = thisArg; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) ); + throw new TypeError( format( '0j2Bi', len ) ); } } else if ( isPositiveInteger( arity ) ) { len = arity; diff --git a/package.json b/package.json index f94e0f3..72bd40f 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-function": "^0.0.x", "@stdlib/assert-is-positive-integer": "^0.0.x", - "@stdlib/string-format": "^0.0.x" + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/bench": "^0.0.x", From 3f0583ae45fdb8449b09ae44a5e85d077c99d1ef Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 2 Oct 2022 00:16:39 +0000 Subject: [PATCH 021/140] Remove files --- index.d.ts | 82 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2776 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 689a825..0000000 --- a/index.d.ts +++ /dev/null @@ -1,82 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Curry function. -* -* @param v - curried function parameter -* @returns partially applied curry function or curried function result -*/ -type Closure = ( v: any ) => any; - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param arity - number of parameters -* @param thisArg - evaluation context -* @throws `arity` must be a positive integer -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight( fcn: Function, arity: number, thisArg?: any ): Closure; // tslint-disable-line max-line-length - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param thisArg - evaluation context -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight( fcn: Function, thisArg?: any ): Closure; - - -// EXPORTS // - -export = curryRight; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 6fe3633..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,i,s){var o,a;if(!e(n))throw new TypeError(r("0j23p",n));if(arguments.length<2){if(a=n.length,!t(a))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",a))}else if(arguments.length>2){if(o=s,!t(a=i))throw new TypeError(r("0j2Bi",a))}else if(t(i))a=i;else{if(a=n.length,!t(a))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",a));o=i}return l([]);function l(e){return function(t){var r=e.slice();if(r.unshift(t),r.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '0j2Bi', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","v","cargs","slice","unshift","apply"],"mappings":";;oSAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,SAE3H,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAEjC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,IAEjID,EAAUF,EAEX,OAAOU,EAAe,IAStB,SAASA,EAAeC,GACvB,OASA,SAAkBC,GACjB,IAAIC,EAAQF,EAAKG,QAEjB,GADAD,EAAME,QAASH,GACVC,EAAML,OAASL,EACnB,OAAOO,EAAeG,GAEvB,OAAOd,EAAIiB,MAAOd,EAASW"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index bb9b3ad..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 818e97924d638417d113dd9c91215dc60034ed41 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 2 Oct 2022 00:17:39 +0000 Subject: [PATCH 022/140] 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 | 39 +- benchmark/benchmark.js | 90 - branches.md | 53 - docs/repl.txt | 53 - docs/types/test.ts | 44 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 110 - package.json | 55 +- stats.html | 2689 +++++++++++++++++++++ test/test.js | 291 --- 37 files changed, 2712 insertions(+), 3703 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 a140481..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-10-01T01:30:05.919Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2b7fad0..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/curry-right) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 26300c3..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/curry-right) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 + + ```
@@ -247,7 +240,7 @@ console.log( out ); ## 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]. @@ -309,11 +302,11 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry +[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry/tree/esm -[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry +[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry/tree/esm -[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right +[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index fbb976c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isFunction = require( '@stdlib/assert-is-function' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var curryRight = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = curryRight( pow ); - if ( typeof out !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( out ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::returned_function', function benchmark( b ) { - var fcn; - var out; - var i; - - fcn = curryRight( pow ); - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = fcn( randu() )( randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::direct', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = pow( randu(), randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 9ed19d3..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/curry-right" -click B href "https://github.com/stdlib-js/utils-curry-right/tree/main" -click C href "https://github.com/stdlib-js/utils-curry-right/tree/production" -click D href "https://github.com/stdlib-js/utils-curry-right/tree/esm" -click E href "https://github.com/stdlib-js/utils-curry-right/tree/deno" -click F href "https://github.com/stdlib-js/utils-curry-right/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/curry-right -[production-url]: https://github.com/stdlib-js/utils-curry-right/tree/production -[deno-url]: https://github.com/stdlib-js/utils-curry-right/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-curry-right/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-curry-right/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7271aed..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,53 +0,0 @@ - -{{alias}}( fcn[, arity][, thisArg] ) - Transforms a function into a sequence of functions each accepting a single - argument. - - Until return value resolution, each invocation returns a new partially - applied curry function. - - This function applies arguments starting from the right. - - Parameters - ---------- - fcn: Function - Function to curry. - - arity: integer (optional) - Number of parameters. Default: `fcn.length`. - - thisArg: any (optional) - Evaluation context. - - Returns - ------- - out: Function - Curry function. - - Examples - -------- - > function add( x, y ) { return x + y; }; - > var f = {{alias}}( add ); - > var sum = f( 2 )( 3 ) - 5 - - // Supply arity: - > function add() { return arguments[ 0 ] + arguments[ 1 ]; }; - > f = {{alias}}( add, 2 ); - > sum = f( 2 )( 3 ) - 5 - - // Provide function context: - > var obj = { - ... 'name': 'Ada', - ... 'greet': function greet( word1, word2 ) { - ... return word1 + ' ' + word2 + ', ' + this.name + '!' - ... } - ... }; - > f = {{alias}}( obj.greet, obj ); - > var str = f( 'there' )( 'Hello' ) - 'Hello there, Ada!' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a3b29c4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import curryRight = require( './index' ); - - -// TESTS // - -// The function returns a function... -{ - curryRight( ( x: number, y: number ): number => x + y ); // $ExpectType Closure - curryRight( ( x: number, y: number ): number => x + y, 2 ); // $ExpectType Closure - curryRight( ( x: number, y: number ): number => x + y, 2, {} ); // $ExpectType Closure -} - -// The compiler throws an error if the function is provided a first argument other than a function... -{ - curryRight( true ); // $ExpectError - curryRight( false ); // $ExpectError - curryRight( 5 ); // $ExpectError - curryRight( [] ); // $ExpectError - curryRight( {} ); // $ExpectError - curryRight( 'abc' ); // $ExpectError -} - -// The compiler throws an error if the function is provided more than three arguments... -{ - curryRight( ( x: number, y: number ): number => x + y, 2, {}, 4 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 76818ec..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 curryRight = require( './../lib' ); - -var fcn; -var out; -var i; - -function add( x, y, z, w, t, s ) { - return x + y + z + w + t + s; -} - -fcn = curryRight( add ); -out = fcn; -for ( i = 0; i < add.length; i++ ) { - out = out( i*10 ); -} -console.log( out ); 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..6fe3633 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,i,s){var o,a;if(!e(n))throw new TypeError(r("0j23p",n));if(arguments.length<2){if(a=n.length,!t(a))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",a))}else if(arguments.length>2){if(o=s,!t(a=i))throw new TypeError(r("0j2Bi",a))}else if(t(i))a=i;else{if(a=n.length,!t(a))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",a));o=i}return l([]);function l(e){return function(t){var r=e.slice();if(r.unshift(t),r.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '0j2Bi', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","v","cargs","slice","unshift","apply"],"mappings":";;oSAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,SAE3H,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAEjC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,IAEjID,EAAUF,EAEX,OAAOU,EAAe,IAStB,SAASA,EAAeC,GACvB,OASA,SAAkBC,GACjB,IAAIC,EAAQF,EAAKG,QAEjB,GADAD,EAAME,QAASH,GACVC,EAAML,OAASL,EACnB,OAAOO,EAAeG,GAEvB,OAAOd,EAAIiB,MAAOd,EAASW"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 7e7d2e8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform a function into a sequence of functions each accepting a single argument. -* -* @module @stdlib/utils-curry-right -* -* @example -* var curryRight = require( '@stdlib/utils-curry-right' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ - -// 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 6eebd6a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* @param {Function} fcn - function to curry -* @param {PositiveInteger} [arity=fcn.length] - number of parameters -* @param {*} [thisArg] - evaluation context -* @throws {TypeError} first argument must be a function -* @throws {TypeError} first argument must be a function having at least one parameter -* @throws {TypeError} `arity` argument must be a positive integer -* @returns {Function} curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -function curryRight( fcn, arity, thisArg ) { - var context; - var len; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0j23p', fcn ) ); - } - if ( arguments.length < 2 ) { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); - } - } else if ( arguments.length > 2 ) { - len = arity; - context = thisArg; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '0j2Bi', len ) ); - } - } else if ( isPositiveInteger( arity ) ) { - len = arity; - } else { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); - } - context = arity; - } - return createCurried( [] ); - - /** - * Returns a curry function. - * - * @private - * @param {Array} args - arguments - * @returns {Function} curry function - */ - function createCurried( args ) { - return curried; - - /** - * Curry function. - * - * @private - * @param {*} v - curried function parameter - * @returns {(Function|*)} partially applied curry function or curried function result - */ - function curried( v ) { - var cargs = args.slice(); - cargs.unshift( v ); - if ( cargs.length < len ) { - return createCurried( cargs ); - } - return fcn.apply( context, cargs ); - } - } -} - - -// EXPORTS // - -module.exports = curryRight; diff --git a/package.json b/package.json index 72bd40f..3a2ccc5 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Transform a function into a sequence of functions each accepting a single argument.", "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,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-positive-integer": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/bench": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/random-base-randu": "^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..f0a9c74 --- /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 b34eaef..0000000 --- a/test/test.js +++ /dev/null @@ -1,291 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var curryRight = require( './../lib' ); - - -// FUNCTIONS // - -function add( x, y, z ) { - return x + y + z; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof curryRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (1 arg)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (2 args; context)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an arity argument which is not a positive integer (3 args)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - 0, - -1, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( add, value, {} ); - }; - } -}); - -tape( 'the function returns a function', function test( t ) { - var fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function curries a function', function test( t) { - var fcn; - var f; - - fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'for each invocation where the invocation number is less than the arity, the curried function returns a new partially applied curry function', function test( t ) { - var sum; - var f0; - var f1; - var f2; - - // Initial curried function has no partially applied arguments... - f0 = curryRight( add ); - - sum = f0( 1 )( 2 )( 3 ); - t.strictEqual( sum, 6, 'returns 6' ); - - sum = f0( 1 )( 3 )( 5 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f0( 10 )( 20 )( 40 ); - t.strictEqual( sum, 70, 'returns 70' ); - - // If arity greater than 1, first invocation returns a curried function with one partially applied argument... - f1 = f0( 2 ); - - sum = f1( 3 )( 4 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f1( 10 )( 20 ); - t.strictEqual( sum, 32, 'returns 32' ); - - sum = f1( -1 )( -2 ); - t.strictEqual( sum, -1, 'returns -1' ); - - // If arity greater than 2, second invocation returns a curried function with two partially applied arguments... - f2 = f1( 3 ); - - sum = f2( 5 ); - t.strictEqual( sum, 10, 'returns 10' ); - - sum = f2( 6 ); - t.strictEqual( sum, 11, 'returns 11' ); - - sum = f2( 10 ); - t.strictEqual( sum, 15, 'returns 15' ); - - // And so on and so forth... - - t.end(); -}); - -tape( 'the function supports specifying a function arity', function test( t ) { - var fcn; - var f; - - function add() { - return arguments[ 0 ] + arguments[ 1 ] + arguments[ 2 ]; - } - - fcn = curryRight( add, 3 ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'the function supports specifying a function context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate( length, units, type, color ) { - return this.style+': '+length+units+' '+type+' '+color; - } - }; - - fcn = curryRight( context.generate, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); - -tape( 'the function supports specifying a function arity and context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate() { - return this.style+': '+arguments[0]+arguments[1]+' '+arguments[2]+' '+arguments[3]; - } - }; - - fcn = curryRight( context.generate, 4, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); From 86fbca6e7f7beea526429571a4deaa10ca078fd0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 04:09:33 +0000 Subject: [PATCH 023/140] Transform error messages --- lib/main.js | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/main.js b/lib/main.js index 8d7768e..6eebd6a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -52,7 +52,7 @@ function curryRight( fcn, arity, thisArg ) { var context; var len; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0j23p', fcn ) ); } if ( arguments.length < 2 ) { len = fcn.length; @@ -63,7 +63,7 @@ function curryRight( fcn, arity, thisArg ) { len = arity; context = thisArg; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) ); + throw new TypeError( format( '0j2Bi', len ) ); } } else if ( isPositiveInteger( arity ) ) { len = arity; diff --git a/package.json b/package.json index f94e0f3..72bd40f 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-function": "^0.0.x", "@stdlib/assert-is-positive-integer": "^0.0.x", - "@stdlib/string-format": "^0.0.x" + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/bench": "^0.0.x", From c9a3e8a2485b59c4d6e12ada1d04508df1642f75 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 18:32:46 +0000 Subject: [PATCH 024/140] Remove files --- index.d.ts | 82 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2776 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 689a825..0000000 --- a/index.d.ts +++ /dev/null @@ -1,82 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Curry function. -* -* @param v - curried function parameter -* @returns partially applied curry function or curried function result -*/ -type Closure = ( v: any ) => any; - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param arity - number of parameters -* @param thisArg - evaluation context -* @throws `arity` must be a positive integer -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight( fcn: Function, arity: number, thisArg?: any ): Closure; // tslint-disable-line max-line-length - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param thisArg - evaluation context -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight( fcn: Function, thisArg?: any ): Closure; - - -// EXPORTS // - -export = curryRight; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 6fe3633..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,i,s){var o,a;if(!e(n))throw new TypeError(r("0j23p",n));if(arguments.length<2){if(a=n.length,!t(a))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",a))}else if(arguments.length>2){if(o=s,!t(a=i))throw new TypeError(r("0j2Bi",a))}else if(t(i))a=i;else{if(a=n.length,!t(a))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",a));o=i}return l([]);function l(e){return function(t){var r=e.slice();if(r.unshift(t),r.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '0j2Bi', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","v","cargs","slice","unshift","apply"],"mappings":";;oSAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,SAE3H,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAEjC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,IAEjID,EAAUF,EAEX,OAAOU,EAAe,IAStB,SAASA,EAAeC,GACvB,OASA,SAAkBC,GACjB,IAAIC,EAAQF,EAAKG,QAEjB,GADAD,EAAME,QAASH,GACVC,EAAML,OAASL,EACnB,OAAOO,EAAeG,GAEvB,OAAOd,EAAIiB,MAAOd,EAASW"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index f0a9c74..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From ead1e006a5429826763056573d60d3a8ff6bdf66 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Nov 2022 18:33:47 +0000 Subject: [PATCH 025/140] 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 | 39 +- benchmark/benchmark.js | 90 - branches.md | 53 - docs/repl.txt | 53 - docs/types/test.ts | 44 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 110 - package.json | 55 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 291 -- 37 files changed, 4067 insertions(+), 3703 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 a544a6e..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-11-01T01:18:18.600Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2b7fad0..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/curry-right) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 26300c3..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/curry-right) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 b01c884..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: '6 18 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 9113bfe..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,760 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -247,7 +240,7 @@ console.log( out ); ## 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]. @@ -309,11 +302,11 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry +[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry/tree/esm -[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry +[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry/tree/esm -[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right +[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index fbb976c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isFunction = require( '@stdlib/assert-is-function' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var curryRight = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = curryRight( pow ); - if ( typeof out !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( out ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::returned_function', function benchmark( b ) { - var fcn; - var out; - var i; - - fcn = curryRight( pow ); - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = fcn( randu() )( randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::direct', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = pow( randu(), randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 9ed19d3..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/curry-right" -click B href "https://github.com/stdlib-js/utils-curry-right/tree/main" -click C href "https://github.com/stdlib-js/utils-curry-right/tree/production" -click D href "https://github.com/stdlib-js/utils-curry-right/tree/esm" -click E href "https://github.com/stdlib-js/utils-curry-right/tree/deno" -click F href "https://github.com/stdlib-js/utils-curry-right/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/curry-right -[production-url]: https://github.com/stdlib-js/utils-curry-right/tree/production -[deno-url]: https://github.com/stdlib-js/utils-curry-right/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-curry-right/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-curry-right/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7271aed..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,53 +0,0 @@ - -{{alias}}( fcn[, arity][, thisArg] ) - Transforms a function into a sequence of functions each accepting a single - argument. - - Until return value resolution, each invocation returns a new partially - applied curry function. - - This function applies arguments starting from the right. - - Parameters - ---------- - fcn: Function - Function to curry. - - arity: integer (optional) - Number of parameters. Default: `fcn.length`. - - thisArg: any (optional) - Evaluation context. - - Returns - ------- - out: Function - Curry function. - - Examples - -------- - > function add( x, y ) { return x + y; }; - > var f = {{alias}}( add ); - > var sum = f( 2 )( 3 ) - 5 - - // Supply arity: - > function add() { return arguments[ 0 ] + arguments[ 1 ]; }; - > f = {{alias}}( add, 2 ); - > sum = f( 2 )( 3 ) - 5 - - // Provide function context: - > var obj = { - ... 'name': 'Ada', - ... 'greet': function greet( word1, word2 ) { - ... return word1 + ' ' + word2 + ', ' + this.name + '!' - ... } - ... }; - > f = {{alias}}( obj.greet, obj ); - > var str = f( 'there' )( 'Hello' ) - 'Hello there, Ada!' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a3b29c4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import curryRight = require( './index' ); - - -// TESTS // - -// The function returns a function... -{ - curryRight( ( x: number, y: number ): number => x + y ); // $ExpectType Closure - curryRight( ( x: number, y: number ): number => x + y, 2 ); // $ExpectType Closure - curryRight( ( x: number, y: number ): number => x + y, 2, {} ); // $ExpectType Closure -} - -// The compiler throws an error if the function is provided a first argument other than a function... -{ - curryRight( true ); // $ExpectError - curryRight( false ); // $ExpectError - curryRight( 5 ); // $ExpectError - curryRight( [] ); // $ExpectError - curryRight( {} ); // $ExpectError - curryRight( 'abc' ); // $ExpectError -} - -// The compiler throws an error if the function is provided more than three arguments... -{ - curryRight( ( x: number, y: number ): number => x + y, 2, {}, 4 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 76818ec..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 curryRight = require( './../lib' ); - -var fcn; -var out; -var i; - -function add( x, y, z, w, t, s ) { - return x + y + z + w + t + s; -} - -fcn = curryRight( add ); -out = fcn; -for ( i = 0; i < add.length; i++ ) { - out = out( i*10 ); -} -console.log( out ); 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..6fe3633 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,i,s){var o,a;if(!e(n))throw new TypeError(r("0j23p",n));if(arguments.length<2){if(a=n.length,!t(a))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",a))}else if(arguments.length>2){if(o=s,!t(a=i))throw new TypeError(r("0j2Bi",a))}else if(t(i))a=i;else{if(a=n.length,!t(a))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",a));o=i}return l([]);function l(e){return function(t){var r=e.slice();if(r.unshift(t),r.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '0j2Bi', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","v","cargs","slice","unshift","apply"],"mappings":";;oSAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,SAE3H,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAEjC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,IAEjID,EAAUF,CACV,CACD,OAAOU,EAAe,IAStB,SAASA,EAAeC,GACvB,OASA,SAAkBC,GACjB,IAAIC,EAAQF,EAAKG,QAEjB,GADAD,EAAME,QAASH,GACVC,EAAML,OAASL,EACnB,OAAOO,EAAeG,GAEvB,OAAOd,EAAIiB,MAAOd,EAASW,EAC3B,CACD,CACF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 7e7d2e8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform a function into a sequence of functions each accepting a single argument. -* -* @module @stdlib/utils-curry-right -* -* @example -* var curryRight = require( '@stdlib/utils-curry-right' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ - -// 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 6eebd6a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* @param {Function} fcn - function to curry -* @param {PositiveInteger} [arity=fcn.length] - number of parameters -* @param {*} [thisArg] - evaluation context -* @throws {TypeError} first argument must be a function -* @throws {TypeError} first argument must be a function having at least one parameter -* @throws {TypeError} `arity` argument must be a positive integer -* @returns {Function} curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -function curryRight( fcn, arity, thisArg ) { - var context; - var len; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0j23p', fcn ) ); - } - if ( arguments.length < 2 ) { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); - } - } else if ( arguments.length > 2 ) { - len = arity; - context = thisArg; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '0j2Bi', len ) ); - } - } else if ( isPositiveInteger( arity ) ) { - len = arity; - } else { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); - } - context = arity; - } - return createCurried( [] ); - - /** - * Returns a curry function. - * - * @private - * @param {Array} args - arguments - * @returns {Function} curry function - */ - function createCurried( args ) { - return curried; - - /** - * Curry function. - * - * @private - * @param {*} v - curried function parameter - * @returns {(Function|*)} partially applied curry function or curried function result - */ - function curried( v ) { - var cargs = args.slice(); - cargs.unshift( v ); - if ( cargs.length < len ) { - return createCurried( cargs ); - } - return fcn.apply( context, cargs ); - } - } -} - - -// EXPORTS // - -module.exports = curryRight; diff --git a/package.json b/package.json index 72bd40f..3a2ccc5 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Transform a function into a sequence of functions each accepting a single argument.", "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,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-positive-integer": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/bench": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/random-base-randu": "^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..a8825ca --- /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 b34eaef..0000000 --- a/test/test.js +++ /dev/null @@ -1,291 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var curryRight = require( './../lib' ); - - -// FUNCTIONS // - -function add( x, y, z ) { - return x + y + z; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof curryRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (1 arg)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (2 args; context)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an arity argument which is not a positive integer (3 args)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - 0, - -1, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( add, value, {} ); - }; - } -}); - -tape( 'the function returns a function', function test( t ) { - var fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function curries a function', function test( t) { - var fcn; - var f; - - fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'for each invocation where the invocation number is less than the arity, the curried function returns a new partially applied curry function', function test( t ) { - var sum; - var f0; - var f1; - var f2; - - // Initial curried function has no partially applied arguments... - f0 = curryRight( add ); - - sum = f0( 1 )( 2 )( 3 ); - t.strictEqual( sum, 6, 'returns 6' ); - - sum = f0( 1 )( 3 )( 5 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f0( 10 )( 20 )( 40 ); - t.strictEqual( sum, 70, 'returns 70' ); - - // If arity greater than 1, first invocation returns a curried function with one partially applied argument... - f1 = f0( 2 ); - - sum = f1( 3 )( 4 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f1( 10 )( 20 ); - t.strictEqual( sum, 32, 'returns 32' ); - - sum = f1( -1 )( -2 ); - t.strictEqual( sum, -1, 'returns -1' ); - - // If arity greater than 2, second invocation returns a curried function with two partially applied arguments... - f2 = f1( 3 ); - - sum = f2( 5 ); - t.strictEqual( sum, 10, 'returns 10' ); - - sum = f2( 6 ); - t.strictEqual( sum, 11, 'returns 11' ); - - sum = f2( 10 ); - t.strictEqual( sum, 15, 'returns 15' ); - - // And so on and so forth... - - t.end(); -}); - -tape( 'the function supports specifying a function arity', function test( t ) { - var fcn; - var f; - - function add() { - return arguments[ 0 ] + arguments[ 1 ] + arguments[ 2 ]; - } - - fcn = curryRight( add, 3 ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'the function supports specifying a function context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate( length, units, type, color ) { - return this.style+': '+length+units+' '+type+' '+color; - } - }; - - fcn = curryRight( context.generate, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); - -tape( 'the function supports specifying a function arity and context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate() { - return this.style+': '+arguments[0]+arguments[1]+' '+arguments[2]+' '+arguments[3]; - } - }; - - fcn = curryRight( context.generate, 4, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); From 14d98b1de73b64b99be0b34090c899f152378fd8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 00:03:17 +0000 Subject: [PATCH 026/140] Transform error messages --- lib/main.js | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/main.js b/lib/main.js index 8d7768e..6eebd6a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -52,7 +52,7 @@ function curryRight( fcn, arity, thisArg ) { var context; var len; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0j23p', fcn ) ); } if ( arguments.length < 2 ) { len = fcn.length; @@ -63,7 +63,7 @@ function curryRight( fcn, arity, thisArg ) { len = arity; context = thisArg; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) ); + throw new TypeError( format( '0j2Bi', len ) ); } } else if ( isPositiveInteger( arity ) ) { len = arity; diff --git a/package.json b/package.json index f94e0f3..72bd40f 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-function": "^0.0.x", "@stdlib/assert-is-positive-integer": "^0.0.x", - "@stdlib/string-format": "^0.0.x" + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/bench": "^0.0.x", From e9cc5c3a5c4e9f78f22304da1992b8865f1c9992 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 10:26:38 +0000 Subject: [PATCH 027/140] Remove files --- index.d.ts | 82 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4131 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 689a825..0000000 --- a/index.d.ts +++ /dev/null @@ -1,82 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Curry function. -* -* @param v - curried function parameter -* @returns partially applied curry function or curried function result -*/ -type Closure = ( v: any ) => any; - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param arity - number of parameters -* @param thisArg - evaluation context -* @throws `arity` must be a positive integer -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight( fcn: Function, arity: number, thisArg?: any ): Closure; // tslint-disable-line max-line-length - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param thisArg - evaluation context -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight( fcn: Function, thisArg?: any ): Closure; - - -// EXPORTS // - -export = curryRight; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 6fe3633..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,i,s){var o,a;if(!e(n))throw new TypeError(r("0j23p",n));if(arguments.length<2){if(a=n.length,!t(a))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",a))}else if(arguments.length>2){if(o=s,!t(a=i))throw new TypeError(r("0j2Bi",a))}else if(t(i))a=i;else{if(a=n.length,!t(a))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",a));o=i}return l([]);function l(e){return function(t){var r=e.slice();if(r.unshift(t),r.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '0j2Bi', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","v","cargs","slice","unshift","apply"],"mappings":";;oSAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,SAE3H,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAEjC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,IAEjID,EAAUF,CACV,CACD,OAAOU,EAAe,IAStB,SAASA,EAAeC,GACvB,OASA,SAAkBC,GACjB,IAAIC,EAAQF,EAAKG,QAEjB,GADAD,EAAME,QAASH,GACVC,EAAML,OAASL,EACnB,OAAOO,EAAeG,GAEvB,OAAOd,EAAIiB,MAAOd,EAASW,EAC3B,CACD,CACF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index a8825ca..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 4ef91e82a2823107af72e72536419ea757e82ebb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 10:27:17 +0000 Subject: [PATCH 028/140] 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 | 39 +- benchmark/benchmark.js | 90 - branches.md | 53 - docs/repl.txt | 53 - docs/types/test.ts | 44 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 110 - package.json | 55 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 291 -- 37 files changed, 4067 insertions(+), 3724 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 e287ea5..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-11-03T21:49:12.561Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2b7fad0..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/curry-right) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 26300c3..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/curry-right) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 b01c884..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: '6 18 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 37ddb4f..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,781 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -247,7 +240,7 @@ console.log( out ); ## 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]. @@ -309,11 +302,11 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry +[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry/tree/esm -[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry +[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry/tree/esm -[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right +[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index fbb976c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isFunction = require( '@stdlib/assert-is-function' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var curryRight = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = curryRight( pow ); - if ( typeof out !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( out ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::returned_function', function benchmark( b ) { - var fcn; - var out; - var i; - - fcn = curryRight( pow ); - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = fcn( randu() )( randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::direct', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = pow( randu(), randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 9ed19d3..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/curry-right" -click B href "https://github.com/stdlib-js/utils-curry-right/tree/main" -click C href "https://github.com/stdlib-js/utils-curry-right/tree/production" -click D href "https://github.com/stdlib-js/utils-curry-right/tree/esm" -click E href "https://github.com/stdlib-js/utils-curry-right/tree/deno" -click F href "https://github.com/stdlib-js/utils-curry-right/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/curry-right -[production-url]: https://github.com/stdlib-js/utils-curry-right/tree/production -[deno-url]: https://github.com/stdlib-js/utils-curry-right/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-curry-right/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-curry-right/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7271aed..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,53 +0,0 @@ - -{{alias}}( fcn[, arity][, thisArg] ) - Transforms a function into a sequence of functions each accepting a single - argument. - - Until return value resolution, each invocation returns a new partially - applied curry function. - - This function applies arguments starting from the right. - - Parameters - ---------- - fcn: Function - Function to curry. - - arity: integer (optional) - Number of parameters. Default: `fcn.length`. - - thisArg: any (optional) - Evaluation context. - - Returns - ------- - out: Function - Curry function. - - Examples - -------- - > function add( x, y ) { return x + y; }; - > var f = {{alias}}( add ); - > var sum = f( 2 )( 3 ) - 5 - - // Supply arity: - > function add() { return arguments[ 0 ] + arguments[ 1 ]; }; - > f = {{alias}}( add, 2 ); - > sum = f( 2 )( 3 ) - 5 - - // Provide function context: - > var obj = { - ... 'name': 'Ada', - ... 'greet': function greet( word1, word2 ) { - ... return word1 + ' ' + word2 + ', ' + this.name + '!' - ... } - ... }; - > f = {{alias}}( obj.greet, obj ); - > var str = f( 'there' )( 'Hello' ) - 'Hello there, Ada!' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a3b29c4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import curryRight = require( './index' ); - - -// TESTS // - -// The function returns a function... -{ - curryRight( ( x: number, y: number ): number => x + y ); // $ExpectType Closure - curryRight( ( x: number, y: number ): number => x + y, 2 ); // $ExpectType Closure - curryRight( ( x: number, y: number ): number => x + y, 2, {} ); // $ExpectType Closure -} - -// The compiler throws an error if the function is provided a first argument other than a function... -{ - curryRight( true ); // $ExpectError - curryRight( false ); // $ExpectError - curryRight( 5 ); // $ExpectError - curryRight( [] ); // $ExpectError - curryRight( {} ); // $ExpectError - curryRight( 'abc' ); // $ExpectError -} - -// The compiler throws an error if the function is provided more than three arguments... -{ - curryRight( ( x: number, y: number ): number => x + y, 2, {}, 4 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 76818ec..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 curryRight = require( './../lib' ); - -var fcn; -var out; -var i; - -function add( x, y, z, w, t, s ) { - return x + y + z + w + t + s; -} - -fcn = curryRight( add ); -out = fcn; -for ( i = 0; i < add.length; i++ ) { - out = out( i*10 ); -} -console.log( out ); 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..6fe3633 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,i,s){var o,a;if(!e(n))throw new TypeError(r("0j23p",n));if(arguments.length<2){if(a=n.length,!t(a))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",a))}else if(arguments.length>2){if(o=s,!t(a=i))throw new TypeError(r("0j2Bi",a))}else if(t(i))a=i;else{if(a=n.length,!t(a))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",a));o=i}return l([]);function l(e){return function(t){var r=e.slice();if(r.unshift(t),r.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '0j2Bi', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","v","cargs","slice","unshift","apply"],"mappings":";;oSAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,SAE3H,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAEjC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,IAEjID,EAAUF,CACV,CACD,OAAOU,EAAe,IAStB,SAASA,EAAeC,GACvB,OASA,SAAkBC,GACjB,IAAIC,EAAQF,EAAKG,QAEjB,GADAD,EAAME,QAASH,GACVC,EAAML,OAASL,EACnB,OAAOO,EAAeG,GAEvB,OAAOd,EAAIiB,MAAOd,EAASW,EAC3B,CACD,CACF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 7e7d2e8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform a function into a sequence of functions each accepting a single argument. -* -* @module @stdlib/utils-curry-right -* -* @example -* var curryRight = require( '@stdlib/utils-curry-right' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ - -// 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 6eebd6a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* @param {Function} fcn - function to curry -* @param {PositiveInteger} [arity=fcn.length] - number of parameters -* @param {*} [thisArg] - evaluation context -* @throws {TypeError} first argument must be a function -* @throws {TypeError} first argument must be a function having at least one parameter -* @throws {TypeError} `arity` argument must be a positive integer -* @returns {Function} curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -function curryRight( fcn, arity, thisArg ) { - var context; - var len; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0j23p', fcn ) ); - } - if ( arguments.length < 2 ) { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); - } - } else if ( arguments.length > 2 ) { - len = arity; - context = thisArg; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '0j2Bi', len ) ); - } - } else if ( isPositiveInteger( arity ) ) { - len = arity; - } else { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); - } - context = arity; - } - return createCurried( [] ); - - /** - * Returns a curry function. - * - * @private - * @param {Array} args - arguments - * @returns {Function} curry function - */ - function createCurried( args ) { - return curried; - - /** - * Curry function. - * - * @private - * @param {*} v - curried function parameter - * @returns {(Function|*)} partially applied curry function or curried function result - */ - function curried( v ) { - var cargs = args.slice(); - cargs.unshift( v ); - if ( cargs.length < len ) { - return createCurried( cargs ); - } - return fcn.apply( context, cargs ); - } - } -} - - -// EXPORTS // - -module.exports = curryRight; diff --git a/package.json b/package.json index 72bd40f..3a2ccc5 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Transform a function into a sequence of functions each accepting a single argument.", "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,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-positive-integer": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/bench": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/random-base-randu": "^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..8f37ac1 --- /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 b34eaef..0000000 --- a/test/test.js +++ /dev/null @@ -1,291 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var curryRight = require( './../lib' ); - - -// FUNCTIONS // - -function add( x, y, z ) { - return x + y + z; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof curryRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (1 arg)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (2 args; context)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an arity argument which is not a positive integer (3 args)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - 0, - -1, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( add, value, {} ); - }; - } -}); - -tape( 'the function returns a function', function test( t ) { - var fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function curries a function', function test( t) { - var fcn; - var f; - - fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'for each invocation where the invocation number is less than the arity, the curried function returns a new partially applied curry function', function test( t ) { - var sum; - var f0; - var f1; - var f2; - - // Initial curried function has no partially applied arguments... - f0 = curryRight( add ); - - sum = f0( 1 )( 2 )( 3 ); - t.strictEqual( sum, 6, 'returns 6' ); - - sum = f0( 1 )( 3 )( 5 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f0( 10 )( 20 )( 40 ); - t.strictEqual( sum, 70, 'returns 70' ); - - // If arity greater than 1, first invocation returns a curried function with one partially applied argument... - f1 = f0( 2 ); - - sum = f1( 3 )( 4 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f1( 10 )( 20 ); - t.strictEqual( sum, 32, 'returns 32' ); - - sum = f1( -1 )( -2 ); - t.strictEqual( sum, -1, 'returns -1' ); - - // If arity greater than 2, second invocation returns a curried function with two partially applied arguments... - f2 = f1( 3 ); - - sum = f2( 5 ); - t.strictEqual( sum, 10, 'returns 10' ); - - sum = f2( 6 ); - t.strictEqual( sum, 11, 'returns 11' ); - - sum = f2( 10 ); - t.strictEqual( sum, 15, 'returns 15' ); - - // And so on and so forth... - - t.end(); -}); - -tape( 'the function supports specifying a function arity', function test( t ) { - var fcn; - var f; - - function add() { - return arguments[ 0 ] + arguments[ 1 ] + arguments[ 2 ]; - } - - fcn = curryRight( add, 3 ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'the function supports specifying a function context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate( length, units, type, color ) { - return this.style+': '+length+units+' '+type+' '+color; - } - }; - - fcn = curryRight( context.generate, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); - -tape( 'the function supports specifying a function arity and context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate() { - return this.style+': '+arguments[0]+arguments[1]+' '+arguments[2]+' '+arguments[3]; - } - }; - - fcn = curryRight( context.generate, 4, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); From 6e941124f1957e0e6ed3aed5e371d2c87b4071d6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 02:06:26 +0000 Subject: [PATCH 029/140] Transform error messages --- lib/main.js | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/main.js b/lib/main.js index 8d7768e..6eebd6a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -52,7 +52,7 @@ function curryRight( fcn, arity, thisArg ) { var context; var len; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0j23p', fcn ) ); } if ( arguments.length < 2 ) { len = fcn.length; @@ -63,7 +63,7 @@ function curryRight( fcn, arity, thisArg ) { len = arity; context = thisArg; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) ); + throw new TypeError( format( '0j2Bi', len ) ); } } else if ( isPositiveInteger( arity ) ) { len = arity; diff --git a/package.json b/package.json index ee6dc65..2914147 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-function": "^0.0.x", "@stdlib/assert-is-positive-integer": "^0.0.x", - "@stdlib/string-format": "^0.0.x" + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/bench": "^0.0.x", From 4328fc704fe6742d9aba3a19fb0c21b633b06b57 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 14:52:53 +0000 Subject: [PATCH 030/140] Remove files --- index.d.ts | 82 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4131 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 689a825..0000000 --- a/index.d.ts +++ /dev/null @@ -1,82 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Curry function. -* -* @param v - curried function parameter -* @returns partially applied curry function or curried function result -*/ -type Closure = ( v: any ) => any; - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param arity - number of parameters -* @param thisArg - evaluation context -* @throws `arity` must be a positive integer -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight( fcn: Function, arity: number, thisArg?: any ): Closure; // tslint-disable-line max-line-length - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param thisArg - evaluation context -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight( fcn: Function, thisArg?: any ): Closure; - - -// EXPORTS // - -export = curryRight; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 6fe3633..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,i,s){var o,a;if(!e(n))throw new TypeError(r("0j23p",n));if(arguments.length<2){if(a=n.length,!t(a))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",a))}else if(arguments.length>2){if(o=s,!t(a=i))throw new TypeError(r("0j2Bi",a))}else if(t(i))a=i;else{if(a=n.length,!t(a))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",a));o=i}return l([]);function l(e){return function(t){var r=e.slice();if(r.unshift(t),r.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '0j2Bi', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","v","cargs","slice","unshift","apply"],"mappings":";;oSAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,SAE3H,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAEjC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,IAEjID,EAAUF,CACV,CACD,OAAOU,EAAe,IAStB,SAASA,EAAeC,GACvB,OASA,SAAkBC,GACjB,IAAIC,EAAQF,EAAKG,QAEjB,GADAD,EAAME,QAASH,GACVC,EAAML,OAASL,EACnB,OAAOO,EAAeG,GAEvB,OAAOd,EAAIiB,MAAOd,EAASW,EAC3B,CACD,CACF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 8f37ac1..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 387a06e7780a6f15f449eed35e8cfd5aad832cc6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 14:53:55 +0000 Subject: [PATCH 031/140] 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 | 39 +- benchmark/benchmark.js | 90 - branches.md | 53 - docs/repl.txt | 53 - docs/types/test.ts | 44 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 110 - package.json | 55 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 291 -- 37 files changed, 4067 insertions(+), 3729 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (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 999d1ed..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-12-01T01:39:04.102Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2b7fad0..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/curry-right) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 26300c3..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/curry-right) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 b01c884..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: '6 18 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 37ddb4f..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,781 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -247,7 +240,7 @@ console.log( out ); ## 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]. @@ -309,11 +302,11 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry +[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry/tree/esm -[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry +[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry/tree/esm -[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right +[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index fbb976c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isFunction = require( '@stdlib/assert-is-function' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var curryRight = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = curryRight( pow ); - if ( typeof out !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( out ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::returned_function', function benchmark( b ) { - var fcn; - var out; - var i; - - fcn = curryRight( pow ); - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = fcn( randu() )( randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::direct', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = pow( randu(), randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 9ed19d3..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/curry-right" -click B href "https://github.com/stdlib-js/utils-curry-right/tree/main" -click C href "https://github.com/stdlib-js/utils-curry-right/tree/production" -click D href "https://github.com/stdlib-js/utils-curry-right/tree/esm" -click E href "https://github.com/stdlib-js/utils-curry-right/tree/deno" -click F href "https://github.com/stdlib-js/utils-curry-right/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/curry-right -[production-url]: https://github.com/stdlib-js/utils-curry-right/tree/production -[deno-url]: https://github.com/stdlib-js/utils-curry-right/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-curry-right/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-curry-right/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7271aed..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,53 +0,0 @@ - -{{alias}}( fcn[, arity][, thisArg] ) - Transforms a function into a sequence of functions each accepting a single - argument. - - Until return value resolution, each invocation returns a new partially - applied curry function. - - This function applies arguments starting from the right. - - Parameters - ---------- - fcn: Function - Function to curry. - - arity: integer (optional) - Number of parameters. Default: `fcn.length`. - - thisArg: any (optional) - Evaluation context. - - Returns - ------- - out: Function - Curry function. - - Examples - -------- - > function add( x, y ) { return x + y; }; - > var f = {{alias}}( add ); - > var sum = f( 2 )( 3 ) - 5 - - // Supply arity: - > function add() { return arguments[ 0 ] + arguments[ 1 ]; }; - > f = {{alias}}( add, 2 ); - > sum = f( 2 )( 3 ) - 5 - - // Provide function context: - > var obj = { - ... 'name': 'Ada', - ... 'greet': function greet( word1, word2 ) { - ... return word1 + ' ' + word2 + ', ' + this.name + '!' - ... } - ... }; - > f = {{alias}}( obj.greet, obj ); - > var str = f( 'there' )( 'Hello' ) - 'Hello there, Ada!' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a3b29c4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import curryRight = require( './index' ); - - -// TESTS // - -// The function returns a function... -{ - curryRight( ( x: number, y: number ): number => x + y ); // $ExpectType Closure - curryRight( ( x: number, y: number ): number => x + y, 2 ); // $ExpectType Closure - curryRight( ( x: number, y: number ): number => x + y, 2, {} ); // $ExpectType Closure -} - -// The compiler throws an error if the function is provided a first argument other than a function... -{ - curryRight( true ); // $ExpectError - curryRight( false ); // $ExpectError - curryRight( 5 ); // $ExpectError - curryRight( [] ); // $ExpectError - curryRight( {} ); // $ExpectError - curryRight( 'abc' ); // $ExpectError -} - -// The compiler throws an error if the function is provided more than three arguments... -{ - curryRight( ( x: number, y: number ): number => x + y, 2, {}, 4 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 76818ec..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 curryRight = require( './../lib' ); - -var fcn; -var out; -var i; - -function add( x, y, z, w, t, s ) { - return x + y + z + w + t + s; -} - -fcn = curryRight( add ); -out = fcn; -for ( i = 0; i < add.length; i++ ) { - out = out( i*10 ); -} -console.log( out ); 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..6fe3633 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,i,s){var o,a;if(!e(n))throw new TypeError(r("0j23p",n));if(arguments.length<2){if(a=n.length,!t(a))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",a))}else if(arguments.length>2){if(o=s,!t(a=i))throw new TypeError(r("0j2Bi",a))}else if(t(i))a=i;else{if(a=n.length,!t(a))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",a));o=i}return l([]);function l(e){return function(t){var r=e.slice();if(r.unshift(t),r.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '0j2Bi', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","v","cargs","slice","unshift","apply"],"mappings":";;oSAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,SAE3H,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAEjC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,IAEjID,EAAUF,CACV,CACD,OAAOU,EAAe,IAStB,SAASA,EAAeC,GACvB,OASA,SAAkBC,GACjB,IAAIC,EAAQF,EAAKG,QAEjB,GADAD,EAAME,QAASH,GACVC,EAAML,OAASL,EACnB,OAAOO,EAAeG,GAEvB,OAAOd,EAAIiB,MAAOd,EAASW,EAC3B,CACD,CACF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 7e7d2e8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform a function into a sequence of functions each accepting a single argument. -* -* @module @stdlib/utils-curry-right -* -* @example -* var curryRight = require( '@stdlib/utils-curry-right' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ - -// 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 6eebd6a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* @param {Function} fcn - function to curry -* @param {PositiveInteger} [arity=fcn.length] - number of parameters -* @param {*} [thisArg] - evaluation context -* @throws {TypeError} first argument must be a function -* @throws {TypeError} first argument must be a function having at least one parameter -* @throws {TypeError} `arity` argument must be a positive integer -* @returns {Function} curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -function curryRight( fcn, arity, thisArg ) { - var context; - var len; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0j23p', fcn ) ); - } - if ( arguments.length < 2 ) { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); - } - } else if ( arguments.length > 2 ) { - len = arity; - context = thisArg; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '0j2Bi', len ) ); - } - } else if ( isPositiveInteger( arity ) ) { - len = arity; - } else { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); - } - context = arity; - } - return createCurried( [] ); - - /** - * Returns a curry function. - * - * @private - * @param {Array} args - arguments - * @returns {Function} curry function - */ - function createCurried( args ) { - return curried; - - /** - * Curry function. - * - * @private - * @param {*} v - curried function parameter - * @returns {(Function|*)} partially applied curry function or curried function result - */ - function curried( v ) { - var cargs = args.slice(); - cargs.unshift( v ); - if ( cargs.length < len ) { - return createCurried( cargs ); - } - return fcn.apply( context, cargs ); - } - } -} - - -// EXPORTS // - -module.exports = curryRight; diff --git a/package.json b/package.json index 2914147..3a2ccc5 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Transform a function into a sequence of functions each accepting a single argument.", "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,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-positive-integer": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/bench": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/random-base-randu": "^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..263c334 --- /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 b34eaef..0000000 --- a/test/test.js +++ /dev/null @@ -1,291 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var curryRight = require( './../lib' ); - - -// FUNCTIONS // - -function add( x, y, z ) { - return x + y + z; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof curryRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (1 arg)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (2 args; context)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an arity argument which is not a positive integer (3 args)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - 0, - -1, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( add, value, {} ); - }; - } -}); - -tape( 'the function returns a function', function test( t ) { - var fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function curries a function', function test( t) { - var fcn; - var f; - - fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'for each invocation where the invocation number is less than the arity, the curried function returns a new partially applied curry function', function test( t ) { - var sum; - var f0; - var f1; - var f2; - - // Initial curried function has no partially applied arguments... - f0 = curryRight( add ); - - sum = f0( 1 )( 2 )( 3 ); - t.strictEqual( sum, 6, 'returns 6' ); - - sum = f0( 1 )( 3 )( 5 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f0( 10 )( 20 )( 40 ); - t.strictEqual( sum, 70, 'returns 70' ); - - // If arity greater than 1, first invocation returns a curried function with one partially applied argument... - f1 = f0( 2 ); - - sum = f1( 3 )( 4 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f1( 10 )( 20 ); - t.strictEqual( sum, 32, 'returns 32' ); - - sum = f1( -1 )( -2 ); - t.strictEqual( sum, -1, 'returns -1' ); - - // If arity greater than 2, second invocation returns a curried function with two partially applied arguments... - f2 = f1( 3 ); - - sum = f2( 5 ); - t.strictEqual( sum, 10, 'returns 10' ); - - sum = f2( 6 ); - t.strictEqual( sum, 11, 'returns 11' ); - - sum = f2( 10 ); - t.strictEqual( sum, 15, 'returns 15' ); - - // And so on and so forth... - - t.end(); -}); - -tape( 'the function supports specifying a function arity', function test( t ) { - var fcn; - var f; - - function add() { - return arguments[ 0 ] + arguments[ 1 ] + arguments[ 2 ]; - } - - fcn = curryRight( add, 3 ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'the function supports specifying a function context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate( length, units, type, color ) { - return this.style+': '+length+units+' '+type+' '+color; - } - }; - - fcn = curryRight( context.generate, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); - -tape( 'the function supports specifying a function arity and context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate() { - return this.style+': '+arguments[0]+arguments[1]+' '+arguments[2]+' '+arguments[3]; - } - }; - - fcn = curryRight( context.generate, 4, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); From 00b131495dffb4335c0f9bd9a6ad944b28e56c59 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Jan 2023 02:53:23 +0000 Subject: [PATCH 032/140] Transform error messages --- lib/main.js | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/main.js b/lib/main.js index 8d7768e..6eebd6a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -52,7 +52,7 @@ function curryRight( fcn, arity, thisArg ) { var context; var len; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0j23p', fcn ) ); } if ( arguments.length < 2 ) { len = fcn.length; @@ -63,7 +63,7 @@ function curryRight( fcn, arity, thisArg ) { len = arity; context = thisArg; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) ); + throw new TypeError( format( '0j2Bi', len ) ); } } else if ( isPositiveInteger( arity ) ) { len = arity; diff --git a/package.json b/package.json index 46df508..0defa57 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-function": "^0.0.x", "@stdlib/assert-is-positive-integer": "^0.0.x", - "@stdlib/string-format": "^0.0.x" + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/bench": "^0.0.x", From 9e023f61ba838330c0b339e9b19075bf4a990c92 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Jan 2023 09:59:38 +0000 Subject: [PATCH 033/140] Remove files --- index.d.ts | 82 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4131 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 689a825..0000000 --- a/index.d.ts +++ /dev/null @@ -1,82 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Curry function. -* -* @param v - curried function parameter -* @returns partially applied curry function or curried function result -*/ -type Closure = ( v: any ) => any; - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param arity - number of parameters -* @param thisArg - evaluation context -* @throws `arity` must be a positive integer -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight( fcn: Function, arity: number, thisArg?: any ): Closure; // tslint-disable-line max-line-length - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param thisArg - evaluation context -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight( fcn: Function, thisArg?: any ): Closure; - - -// EXPORTS // - -export = curryRight; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 6fe3633..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2022 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,i,s){var o,a;if(!e(n))throw new TypeError(r("0j23p",n));if(arguments.length<2){if(a=n.length,!t(a))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",a))}else if(arguments.length>2){if(o=s,!t(a=i))throw new TypeError(r("0j2Bi",a))}else if(t(i))a=i;else{if(a=n.length,!t(a))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",a));o=i}return l([]);function l(e){return function(t){var r=e.slice();if(r.unshift(t),r.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '0j2Bi', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","v","cargs","slice","unshift","apply"],"mappings":";;oSAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,SAE3H,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAEjC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,IAEjID,EAAUF,CACV,CACD,OAAOU,EAAe,IAStB,SAASA,EAAeC,GACvB,OASA,SAAkBC,GACjB,IAAIC,EAAQF,EAAKG,QAEjB,GADAD,EAAME,QAASH,GACVC,EAAML,OAASL,EACnB,OAAOO,EAAeG,GAEvB,OAAOd,EAAIiB,MAAOd,EAASW,EAC3B,CACD,CACF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 263c334..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 86a56edb23a4aa5c44d7b51ac60c025f41b274b4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Jan 2023 10:00:34 +0000 Subject: [PATCH 034/140] 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 | 39 +- benchmark/benchmark.js | 90 - branches.md | 53 - docs/repl.txt | 53 - docs/types/test.ts | 44 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 110 - package.json | 55 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 291 -- 37 files changed, 4067 insertions(+), 3740 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 bcd8739..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-01-01T01:08:07.270Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2b7fad0..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/curry-right) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 26300c3..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/curry-right) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 b01c884..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: '6 18 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4eea88..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,791 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -247,7 +240,7 @@ console.log( out ); ## 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]. @@ -309,11 +302,11 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry +[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry/tree/esm -[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry +[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry/tree/esm -[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right +[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index fbb976c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isFunction = require( '@stdlib/assert-is-function' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var curryRight = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = curryRight( pow ); - if ( typeof out !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( out ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::returned_function', function benchmark( b ) { - var fcn; - var out; - var i; - - fcn = curryRight( pow ); - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = fcn( randu() )( randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::direct', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = pow( randu(), randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 9ed19d3..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/curry-right" -click B href "https://github.com/stdlib-js/utils-curry-right/tree/main" -click C href "https://github.com/stdlib-js/utils-curry-right/tree/production" -click D href "https://github.com/stdlib-js/utils-curry-right/tree/esm" -click E href "https://github.com/stdlib-js/utils-curry-right/tree/deno" -click F href "https://github.com/stdlib-js/utils-curry-right/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/curry-right -[production-url]: https://github.com/stdlib-js/utils-curry-right/tree/production -[deno-url]: https://github.com/stdlib-js/utils-curry-right/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-curry-right/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-curry-right/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7271aed..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,53 +0,0 @@ - -{{alias}}( fcn[, arity][, thisArg] ) - Transforms a function into a sequence of functions each accepting a single - argument. - - Until return value resolution, each invocation returns a new partially - applied curry function. - - This function applies arguments starting from the right. - - Parameters - ---------- - fcn: Function - Function to curry. - - arity: integer (optional) - Number of parameters. Default: `fcn.length`. - - thisArg: any (optional) - Evaluation context. - - Returns - ------- - out: Function - Curry function. - - Examples - -------- - > function add( x, y ) { return x + y; }; - > var f = {{alias}}( add ); - > var sum = f( 2 )( 3 ) - 5 - - // Supply arity: - > function add() { return arguments[ 0 ] + arguments[ 1 ]; }; - > f = {{alias}}( add, 2 ); - > sum = f( 2 )( 3 ) - 5 - - // Provide function context: - > var obj = { - ... 'name': 'Ada', - ... 'greet': function greet( word1, word2 ) { - ... return word1 + ' ' + word2 + ', ' + this.name + '!' - ... } - ... }; - > f = {{alias}}( obj.greet, obj ); - > var str = f( 'there' )( 'Hello' ) - 'Hello there, Ada!' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a3b29c4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import curryRight = require( './index' ); - - -// TESTS // - -// The function returns a function... -{ - curryRight( ( x: number, y: number ): number => x + y ); // $ExpectType Closure - curryRight( ( x: number, y: number ): number => x + y, 2 ); // $ExpectType Closure - curryRight( ( x: number, y: number ): number => x + y, 2, {} ); // $ExpectType Closure -} - -// The compiler throws an error if the function is provided a first argument other than a function... -{ - curryRight( true ); // $ExpectError - curryRight( false ); // $ExpectError - curryRight( 5 ); // $ExpectError - curryRight( [] ); // $ExpectError - curryRight( {} ); // $ExpectError - curryRight( 'abc' ); // $ExpectError -} - -// The compiler throws an error if the function is provided more than three arguments... -{ - curryRight( ( x: number, y: number ): number => x + y, 2, {}, 4 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 76818ec..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 curryRight = require( './../lib' ); - -var fcn; -var out; -var i; - -function add( x, y, z, w, t, s ) { - return x + y + z + w + t + s; -} - -fcn = curryRight( add ); -out = fcn; -for ( i = 0; i < add.length; i++ ) { - out = out( i*10 ); -} -console.log( out ); 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..b1b41c5 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";function n(n,i,s){var o,a;if(!e(n))throw new TypeError(r("0j23p",n));if(arguments.length<2){if(a=n.length,!t(a))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",a))}else if(arguments.length>2){if(o=s,!t(a=i))throw new TypeError(r("0j2Bi",a))}else if(t(i))a=i;else{if(a=n.length,!t(a))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",a));o=i}return l([]);function l(e){return function(t){var r=e.slice();if(r.unshift(t),r.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '0j2Bi', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","v","cargs","slice","unshift","apply"],"mappings":";;6RAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,SAE3H,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAEjC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,IAEjID,EAAUF,CACV,CACD,OAAOU,EAAe,IAStB,SAASA,EAAeC,GACvB,OASA,SAAkBC,GACjB,IAAIC,EAAQF,EAAKG,QAEjB,GADAD,EAAME,QAASH,GACVC,EAAML,OAASL,EACnB,OAAOO,EAAeG,GAEvB,OAAOd,EAAIiB,MAAOd,EAASW,EAC3B,CACD,CACF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 7e7d2e8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform a function into a sequence of functions each accepting a single argument. -* -* @module @stdlib/utils-curry-right -* -* @example -* var curryRight = require( '@stdlib/utils-curry-right' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ - -// 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 6eebd6a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* @param {Function} fcn - function to curry -* @param {PositiveInteger} [arity=fcn.length] - number of parameters -* @param {*} [thisArg] - evaluation context -* @throws {TypeError} first argument must be a function -* @throws {TypeError} first argument must be a function having at least one parameter -* @throws {TypeError} `arity` argument must be a positive integer -* @returns {Function} curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -function curryRight( fcn, arity, thisArg ) { - var context; - var len; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0j23p', fcn ) ); - } - if ( arguments.length < 2 ) { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); - } - } else if ( arguments.length > 2 ) { - len = arity; - context = thisArg; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '0j2Bi', len ) ); - } - } else if ( isPositiveInteger( arity ) ) { - len = arity; - } else { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); - } - context = arity; - } - return createCurried( [] ); - - /** - * Returns a curry function. - * - * @private - * @param {Array} args - arguments - * @returns {Function} curry function - */ - function createCurried( args ) { - return curried; - - /** - * Curry function. - * - * @private - * @param {*} v - curried function parameter - * @returns {(Function|*)} partially applied curry function or curried function result - */ - function curried( v ) { - var cargs = args.slice(); - cargs.unshift( v ); - if ( cargs.length < len ) { - return createCurried( cargs ); - } - return fcn.apply( context, cargs ); - } - } -} - - -// EXPORTS // - -module.exports = curryRight; diff --git a/package.json b/package.json index 0defa57..3a2ccc5 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Transform a function into a sequence of functions each accepting a single argument.", "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,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-positive-integer": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/bench": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/random-base-randu": "^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..6f092d7 --- /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 b34eaef..0000000 --- a/test/test.js +++ /dev/null @@ -1,291 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var curryRight = require( './../lib' ); - - -// FUNCTIONS // - -function add( x, y, z ) { - return x + y + z; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof curryRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (1 arg)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (2 args; context)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an arity argument which is not a positive integer (3 args)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - 0, - -1, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( add, value, {} ); - }; - } -}); - -tape( 'the function returns a function', function test( t ) { - var fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function curries a function', function test( t) { - var fcn; - var f; - - fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'for each invocation where the invocation number is less than the arity, the curried function returns a new partially applied curry function', function test( t ) { - var sum; - var f0; - var f1; - var f2; - - // Initial curried function has no partially applied arguments... - f0 = curryRight( add ); - - sum = f0( 1 )( 2 )( 3 ); - t.strictEqual( sum, 6, 'returns 6' ); - - sum = f0( 1 )( 3 )( 5 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f0( 10 )( 20 )( 40 ); - t.strictEqual( sum, 70, 'returns 70' ); - - // If arity greater than 1, first invocation returns a curried function with one partially applied argument... - f1 = f0( 2 ); - - sum = f1( 3 )( 4 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f1( 10 )( 20 ); - t.strictEqual( sum, 32, 'returns 32' ); - - sum = f1( -1 )( -2 ); - t.strictEqual( sum, -1, 'returns -1' ); - - // If arity greater than 2, second invocation returns a curried function with two partially applied arguments... - f2 = f1( 3 ); - - sum = f2( 5 ); - t.strictEqual( sum, 10, 'returns 10' ); - - sum = f2( 6 ); - t.strictEqual( sum, 11, 'returns 11' ); - - sum = f2( 10 ); - t.strictEqual( sum, 15, 'returns 15' ); - - // And so on and so forth... - - t.end(); -}); - -tape( 'the function supports specifying a function arity', function test( t ) { - var fcn; - var f; - - function add() { - return arguments[ 0 ] + arguments[ 1 ] + arguments[ 2 ]; - } - - fcn = curryRight( add, 3 ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'the function supports specifying a function context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate( length, units, type, color ) { - return this.style+': '+length+units+' '+type+' '+color; - } - }; - - fcn = curryRight( context.generate, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); - -tape( 'the function supports specifying a function arity and context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate() { - return this.style+': '+arguments[0]+arguments[1]+' '+arguments[2]+' '+arguments[3]; - } - }; - - fcn = curryRight( context.generate, 4, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); From 43e994ca600c69b4952254f8205866df7846b243 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 03:45:43 +0000 Subject: [PATCH 035/140] Transform error messages --- lib/main.js | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/main.js b/lib/main.js index 8d7768e..6eebd6a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -52,7 +52,7 @@ function curryRight( fcn, arity, thisArg ) { var context; var len; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0j23p', fcn ) ); } if ( arguments.length < 2 ) { len = fcn.length; @@ -63,7 +63,7 @@ function curryRight( fcn, arity, thisArg ) { len = arity; context = thisArg; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) ); + throw new TypeError( format( '0j2Bi', len ) ); } } else if ( isPositiveInteger( arity ) ) { len = arity; diff --git a/package.json b/package.json index 46df508..0defa57 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-function": "^0.0.x", "@stdlib/assert-is-positive-integer": "^0.0.x", - "@stdlib/string-format": "^0.0.x" + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/bench": "^0.0.x", From 4dfd41fcf7f60c90b43a2d2f8d63b63f8ad6d345 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 11:58:22 +0000 Subject: [PATCH 036/140] Remove files --- index.d.ts | 82 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4131 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 689a825..0000000 --- a/index.d.ts +++ /dev/null @@ -1,82 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Curry function. -* -* @param v - curried function parameter -* @returns partially applied curry function or curried function result -*/ -type Closure = ( v: any ) => any; - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param arity - number of parameters -* @param thisArg - evaluation context -* @throws `arity` must be a positive integer -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight( fcn: Function, arity: number, thisArg?: any ): Closure; // tslint-disable-line max-line-length - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param thisArg - evaluation context -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight( fcn: Function, thisArg?: any ): Closure; - - -// EXPORTS // - -export = curryRight; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b1b41c5..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";function n(n,i,s){var o,a;if(!e(n))throw new TypeError(r("0j23p",n));if(arguments.length<2){if(a=n.length,!t(a))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",a))}else if(arguments.length>2){if(o=s,!t(a=i))throw new TypeError(r("0j2Bi",a))}else if(t(i))a=i;else{if(a=n.length,!t(a))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",a));o=i}return l([]);function l(e){return function(t){var r=e.slice();if(r.unshift(t),r.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '0j2Bi', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","v","cargs","slice","unshift","apply"],"mappings":";;6RAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,SAE3H,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAEjC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,IAEjID,EAAUF,CACV,CACD,OAAOU,EAAe,IAStB,SAASA,EAAeC,GACvB,OASA,SAAkBC,GACjB,IAAIC,EAAQF,EAAKG,QAEjB,GADAD,EAAME,QAASH,GACVC,EAAML,OAASL,EACnB,OAAOO,EAAeG,GAEvB,OAAOd,EAAIiB,MAAOd,EAASW,EAC3B,CACD,CACF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 6f092d7..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 322f1d3e01a3d7fa9050ab138b45093ad6038f95 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 11:59:16 +0000 Subject: [PATCH 037/140] 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 | 39 +- benchmark/benchmark.js | 90 - branches.md | 53 - docs/repl.txt | 53 - docs/types/test.ts | 44 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 110 - package.json | 55 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 291 - 37 files changed, 6200 insertions(+), 3740 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 059ca52..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-02-01T01:28:47.164Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2b7fad0..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/curry-right) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 26300c3..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/curry-right) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 b01c884..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: '6 18 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4eea88..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,791 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -247,7 +240,7 @@ console.log( out ); ## 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]. @@ -309,11 +302,11 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry +[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry/tree/esm -[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry +[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry/tree/esm -[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right +[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index fbb976c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isFunction = require( '@stdlib/assert-is-function' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var curryRight = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = curryRight( pow ); - if ( typeof out !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( out ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::returned_function', function benchmark( b ) { - var fcn; - var out; - var i; - - fcn = curryRight( pow ); - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = fcn( randu() )( randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::direct', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = pow( randu(), randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 9ed19d3..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/curry-right" -click B href "https://github.com/stdlib-js/utils-curry-right/tree/main" -click C href "https://github.com/stdlib-js/utils-curry-right/tree/production" -click D href "https://github.com/stdlib-js/utils-curry-right/tree/esm" -click E href "https://github.com/stdlib-js/utils-curry-right/tree/deno" -click F href "https://github.com/stdlib-js/utils-curry-right/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/curry-right -[production-url]: https://github.com/stdlib-js/utils-curry-right/tree/production -[deno-url]: https://github.com/stdlib-js/utils-curry-right/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-curry-right/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-curry-right/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7271aed..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,53 +0,0 @@ - -{{alias}}( fcn[, arity][, thisArg] ) - Transforms a function into a sequence of functions each accepting a single - argument. - - Until return value resolution, each invocation returns a new partially - applied curry function. - - This function applies arguments starting from the right. - - Parameters - ---------- - fcn: Function - Function to curry. - - arity: integer (optional) - Number of parameters. Default: `fcn.length`. - - thisArg: any (optional) - Evaluation context. - - Returns - ------- - out: Function - Curry function. - - Examples - -------- - > function add( x, y ) { return x + y; }; - > var f = {{alias}}( add ); - > var sum = f( 2 )( 3 ) - 5 - - // Supply arity: - > function add() { return arguments[ 0 ] + arguments[ 1 ]; }; - > f = {{alias}}( add, 2 ); - > sum = f( 2 )( 3 ) - 5 - - // Provide function context: - > var obj = { - ... 'name': 'Ada', - ... 'greet': function greet( word1, word2 ) { - ... return word1 + ' ' + word2 + ', ' + this.name + '!' - ... } - ... }; - > f = {{alias}}( obj.greet, obj ); - > var str = f( 'there' )( 'Hello' ) - 'Hello there, Ada!' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a3b29c4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import curryRight = require( './index' ); - - -// TESTS // - -// The function returns a function... -{ - curryRight( ( x: number, y: number ): number => x + y ); // $ExpectType Closure - curryRight( ( x: number, y: number ): number => x + y, 2 ); // $ExpectType Closure - curryRight( ( x: number, y: number ): number => x + y, 2, {} ); // $ExpectType Closure -} - -// The compiler throws an error if the function is provided a first argument other than a function... -{ - curryRight( true ); // $ExpectError - curryRight( false ); // $ExpectError - curryRight( 5 ); // $ExpectError - curryRight( [] ); // $ExpectError - curryRight( {} ); // $ExpectError - curryRight( 'abc' ); // $ExpectError -} - -// The compiler throws an error if the function is provided more than three arguments... -{ - curryRight( ( x: number, y: number ): number => x + y, 2, {}, 4 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 76818ec..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 curryRight = require( './../lib' ); - -var fcn; -var out; -var i; - -function add( x, y, z, w, t, s ) { - return x + y + z + w + t + s; -} - -fcn = curryRight( add ); -out = fcn; -for ( i = 0; i < add.length; i++ ) { - out = out( i*10 ); -} -console.log( out ); 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..a30aaa4 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,i,s){var o,a;if(!e(n))throw new TypeError(r("0j23p",n));if(arguments.length<2){if(a=n.length,!t(a))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",a))}else if(arguments.length>2){if(o=s,!t(a=i))throw new TypeError(r("0j2Bi",a))}else if(t(i))a=i;else{if(a=n.length,!t(a))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",a));o=i}return l([]);function l(e){return function(t){var r=e.slice();if(r.unshift(t),r.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '0j2Bi', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","v","cargs","slice","unshift","apply"],"mappings":";;oSAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,SAE3H,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAEjC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,IAEjID,EAAUF,CACV,CACD,OAAOU,EAAe,IAStB,SAASA,EAAeC,GACvB,OASA,SAAkBC,GACjB,IAAIC,EAAQF,EAAKG,QAEjB,GADAD,EAAME,QAASH,GACVC,EAAML,OAASL,EACnB,OAAOO,EAAeG,GAEvB,OAAOd,EAAIiB,MAAOd,EAASW,EAC3B,CACD,CACF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 7e7d2e8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform a function into a sequence of functions each accepting a single argument. -* -* @module @stdlib/utils-curry-right -* -* @example -* var curryRight = require( '@stdlib/utils-curry-right' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ - -// 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 6eebd6a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* @param {Function} fcn - function to curry -* @param {PositiveInteger} [arity=fcn.length] - number of parameters -* @param {*} [thisArg] - evaluation context -* @throws {TypeError} first argument must be a function -* @throws {TypeError} first argument must be a function having at least one parameter -* @throws {TypeError} `arity` argument must be a positive integer -* @returns {Function} curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -function curryRight( fcn, arity, thisArg ) { - var context; - var len; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0j23p', fcn ) ); - } - if ( arguments.length < 2 ) { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); - } - } else if ( arguments.length > 2 ) { - len = arity; - context = thisArg; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '0j2Bi', len ) ); - } - } else if ( isPositiveInteger( arity ) ) { - len = arity; - } else { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); - } - context = arity; - } - return createCurried( [] ); - - /** - * Returns a curry function. - * - * @private - * @param {Array} args - arguments - * @returns {Function} curry function - */ - function createCurried( args ) { - return curried; - - /** - * Curry function. - * - * @private - * @param {*} v - curried function parameter - * @returns {(Function|*)} partially applied curry function or curried function result - */ - function curried( v ) { - var cargs = args.slice(); - cargs.unshift( v ); - if ( cargs.length < len ) { - return createCurried( cargs ); - } - return fcn.apply( context, cargs ); - } - } -} - - -// EXPORTS // - -module.exports = curryRight; diff --git a/package.json b/package.json index 0defa57..3a2ccc5 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Transform a function into a sequence of functions each accepting a single argument.", "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,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.0.x", - "@stdlib/assert-is-positive-integer": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/bench": "^0.0.x", - "@stdlib/math-base-special-pow": "^0.0.x", - "@stdlib/random-base-randu": "^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..ba2521c --- /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 b34eaef..0000000 --- a/test/test.js +++ /dev/null @@ -1,291 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var curryRight = require( './../lib' ); - - -// FUNCTIONS // - -function add( x, y, z ) { - return x + y + z; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof curryRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (1 arg)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (2 args; context)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an arity argument which is not a positive integer (3 args)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - 0, - -1, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( add, value, {} ); - }; - } -}); - -tape( 'the function returns a function', function test( t ) { - var fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function curries a function', function test( t) { - var fcn; - var f; - - fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'for each invocation where the invocation number is less than the arity, the curried function returns a new partially applied curry function', function test( t ) { - var sum; - var f0; - var f1; - var f2; - - // Initial curried function has no partially applied arguments... - f0 = curryRight( add ); - - sum = f0( 1 )( 2 )( 3 ); - t.strictEqual( sum, 6, 'returns 6' ); - - sum = f0( 1 )( 3 )( 5 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f0( 10 )( 20 )( 40 ); - t.strictEqual( sum, 70, 'returns 70' ); - - // If arity greater than 1, first invocation returns a curried function with one partially applied argument... - f1 = f0( 2 ); - - sum = f1( 3 )( 4 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f1( 10 )( 20 ); - t.strictEqual( sum, 32, 'returns 32' ); - - sum = f1( -1 )( -2 ); - t.strictEqual( sum, -1, 'returns -1' ); - - // If arity greater than 2, second invocation returns a curried function with two partially applied arguments... - f2 = f1( 3 ); - - sum = f2( 5 ); - t.strictEqual( sum, 10, 'returns 10' ); - - sum = f2( 6 ); - t.strictEqual( sum, 11, 'returns 11' ); - - sum = f2( 10 ); - t.strictEqual( sum, 15, 'returns 15' ); - - // And so on and so forth... - - t.end(); -}); - -tape( 'the function supports specifying a function arity', function test( t ) { - var fcn; - var f; - - function add() { - return arguments[ 0 ] + arguments[ 1 ] + arguments[ 2 ]; - } - - fcn = curryRight( add, 3 ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'the function supports specifying a function context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate( length, units, type, color ) { - return this.style+': '+length+units+' '+type+' '+color; - } - }; - - fcn = curryRight( context.generate, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); - -tape( 'the function supports specifying a function arity and context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate() { - return this.style+': '+arguments[0]+arguments[1]+' '+arguments[2]+' '+arguments[3]; - } - }; - - fcn = curryRight( context.generate, 4, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); From b752280241258bde8756d30ef91e46064b728e9a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Mar 2023 05:17:20 +0000 Subject: [PATCH 038/140] Transform error messages --- lib/main.js | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/main.js b/lib/main.js index 8d7768e..6eebd6a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -52,7 +52,7 @@ function curryRight( fcn, arity, thisArg ) { var context; var len; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0j23p', fcn ) ); } if ( arguments.length < 2 ) { len = fcn.length; @@ -63,7 +63,7 @@ function curryRight( fcn, arity, thisArg ) { len = arity; context = thisArg; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) ); + throw new TypeError( format( '0j2Bi', len ) ); } } else if ( isPositiveInteger( arity ) ) { len = arity; diff --git a/package.json b/package.json index 2736773..754a6c6 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-function": "^0.0.8", "@stdlib/assert-is-positive-integer": "^0.0.7", - "@stdlib/string-format": "^0.0.3" + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/bench": "^0.0.12", From 9d73307b83b92d6cba02621397e32a15c0d59190 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Mar 2023 12:52:55 +0000 Subject: [PATCH 039/140] Remove files --- index.d.ts | 82 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6264 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 689a825..0000000 --- a/index.d.ts +++ /dev/null @@ -1,82 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Curry function. -* -* @param v - curried function parameter -* @returns partially applied curry function or curried function result -*/ -type Closure = ( v: any ) => any; - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param arity - number of parameters -* @param thisArg - evaluation context -* @throws `arity` must be a positive integer -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight( fcn: Function, arity: number, thisArg?: any ): Closure; // tslint-disable-line max-line-length - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param thisArg - evaluation context -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight( fcn: Function, thisArg?: any ): Closure; - - -// EXPORTS // - -export = curryRight; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index a30aaa4..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,i,s){var o,a;if(!e(n))throw new TypeError(r("0j23p",n));if(arguments.length<2){if(a=n.length,!t(a))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",a))}else if(arguments.length>2){if(o=s,!t(a=i))throw new TypeError(r("0j2Bi",a))}else if(t(i))a=i;else{if(a=n.length,!t(a))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",a));o=i}return l([]);function l(e){return function(t){var r=e.slice();if(r.unshift(t),r.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '0j2Bi', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","v","cargs","slice","unshift","apply"],"mappings":";;oSAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,SAE3H,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAEjC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,IAEjID,EAAUF,CACV,CACD,OAAOU,EAAe,IAStB,SAASA,EAAeC,GACvB,OASA,SAAkBC,GACjB,IAAIC,EAAQF,EAAKG,QAEjB,GADAD,EAAME,QAASH,GACVC,EAAML,OAASL,EACnB,OAAOO,EAAeG,GAEvB,OAAOd,EAAIiB,MAAOd,EAASW,EAC3B,CACD,CACF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index ba2521c..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From e116ad5cbada4c0b6bac5d28d2f145d6a208ce85 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Mar 2023 12:53:52 +0000 Subject: [PATCH 040/140] 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 | 39 +- benchmark/benchmark.js | 90 - branches.md | 53 - docs/repl.txt | 53 - docs/types/test.ts | 44 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 110 - package.json | 55 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 291 - 37 files changed, 6200 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 8313044..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-03-01T03:25:03.350Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2b7fad0..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/curry-right) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 26300c3..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/curry-right) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 b01c884..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: '6 18 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 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 + + ```
@@ -247,7 +240,7 @@ console.log( out ); ## 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]. @@ -309,11 +302,11 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry +[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry/tree/esm -[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry +[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry/tree/esm -[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right +[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index fbb976c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isFunction = require( '@stdlib/assert-is-function' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var curryRight = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = curryRight( pow ); - if ( typeof out !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( out ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::returned_function', function benchmark( b ) { - var fcn; - var out; - var i; - - fcn = curryRight( pow ); - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = fcn( randu() )( randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::direct', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = pow( randu(), randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1f7cde2..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/curry-right" -%% click B href "https://github.com/stdlib-js/utils-curry-right/tree/main" -%% click C href "https://github.com/stdlib-js/utils-curry-right/tree/production" -%% click D href "https://github.com/stdlib-js/utils-curry-right/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-curry-right/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-curry-right/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/curry-right -[production-url]: https://github.com/stdlib-js/utils-curry-right/tree/production -[deno-url]: https://github.com/stdlib-js/utils-curry-right/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-curry-right/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-curry-right/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7271aed..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,53 +0,0 @@ - -{{alias}}( fcn[, arity][, thisArg] ) - Transforms a function into a sequence of functions each accepting a single - argument. - - Until return value resolution, each invocation returns a new partially - applied curry function. - - This function applies arguments starting from the right. - - Parameters - ---------- - fcn: Function - Function to curry. - - arity: integer (optional) - Number of parameters. Default: `fcn.length`. - - thisArg: any (optional) - Evaluation context. - - Returns - ------- - out: Function - Curry function. - - Examples - -------- - > function add( x, y ) { return x + y; }; - > var f = {{alias}}( add ); - > var sum = f( 2 )( 3 ) - 5 - - // Supply arity: - > function add() { return arguments[ 0 ] + arguments[ 1 ]; }; - > f = {{alias}}( add, 2 ); - > sum = f( 2 )( 3 ) - 5 - - // Provide function context: - > var obj = { - ... 'name': 'Ada', - ... 'greet': function greet( word1, word2 ) { - ... return word1 + ' ' + word2 + ', ' + this.name + '!' - ... } - ... }; - > f = {{alias}}( obj.greet, obj ); - > var str = f( 'there' )( 'Hello' ) - 'Hello there, Ada!' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a3b29c4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import curryRight = require( './index' ); - - -// TESTS // - -// The function returns a function... -{ - curryRight( ( x: number, y: number ): number => x + y ); // $ExpectType Closure - curryRight( ( x: number, y: number ): number => x + y, 2 ); // $ExpectType Closure - curryRight( ( x: number, y: number ): number => x + y, 2, {} ); // $ExpectType Closure -} - -// The compiler throws an error if the function is provided a first argument other than a function... -{ - curryRight( true ); // $ExpectError - curryRight( false ); // $ExpectError - curryRight( 5 ); // $ExpectError - curryRight( [] ); // $ExpectError - curryRight( {} ); // $ExpectError - curryRight( 'abc' ); // $ExpectError -} - -// The compiler throws an error if the function is provided more than three arguments... -{ - curryRight( ( x: number, y: number ): number => x + y, 2, {}, 4 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 76818ec..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 curryRight = require( './../lib' ); - -var fcn; -var out; -var i; - -function add( x, y, z, w, t, s ) { - return x + y + z + w + t + s; -} - -fcn = curryRight( add ); -out = fcn; -for ( i = 0; i < add.length; i++ ) { - out = out( i*10 ); -} -console.log( out ); 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..a30aaa4 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,i,s){var o,a;if(!e(n))throw new TypeError(r("0j23p",n));if(arguments.length<2){if(a=n.length,!t(a))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",a))}else if(arguments.length>2){if(o=s,!t(a=i))throw new TypeError(r("0j2Bi",a))}else if(t(i))a=i;else{if(a=n.length,!t(a))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",a));o=i}return l([]);function l(e){return function(t){var r=e.slice();if(r.unshift(t),r.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '0j2Bi', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","v","cargs","slice","unshift","apply"],"mappings":";;oSAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,SAE3H,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAEjC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,IAEjID,EAAUF,CACV,CACD,OAAOU,EAAe,IAStB,SAASA,EAAeC,GACvB,OASA,SAAkBC,GACjB,IAAIC,EAAQF,EAAKG,QAEjB,GADAD,EAAME,QAASH,GACVC,EAAML,OAASL,EACnB,OAAOO,EAAeG,GAEvB,OAAOd,EAAIiB,MAAOd,EAASW,EAC3B,CACD,CACF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 7e7d2e8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform a function into a sequence of functions each accepting a single argument. -* -* @module @stdlib/utils-curry-right -* -* @example -* var curryRight = require( '@stdlib/utils-curry-right' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ - -// 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 6eebd6a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* @param {Function} fcn - function to curry -* @param {PositiveInteger} [arity=fcn.length] - number of parameters -* @param {*} [thisArg] - evaluation context -* @throws {TypeError} first argument must be a function -* @throws {TypeError} first argument must be a function having at least one parameter -* @throws {TypeError} `arity` argument must be a positive integer -* @returns {Function} curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -function curryRight( fcn, arity, thisArg ) { - var context; - var len; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0j23p', fcn ) ); - } - if ( arguments.length < 2 ) { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); - } - } else if ( arguments.length > 2 ) { - len = arity; - context = thisArg; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '0j2Bi', len ) ); - } - } else if ( isPositiveInteger( arity ) ) { - len = arity; - } else { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); - } - context = arity; - } - return createCurried( [] ); - - /** - * Returns a curry function. - * - * @private - * @param {Array} args - arguments - * @returns {Function} curry function - */ - function createCurried( args ) { - return curried; - - /** - * Curry function. - * - * @private - * @param {*} v - curried function parameter - * @returns {(Function|*)} partially applied curry function or curried function result - */ - function curried( v ) { - var cargs = args.slice(); - cargs.unshift( v ); - if ( cargs.length < len ) { - return createCurried( cargs ); - } - return fcn.apply( context, cargs ); - } - } -} - - -// EXPORTS // - -module.exports = curryRight; diff --git a/package.json b/package.json index 754a6c6..b53b05c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Transform a function into a sequence of functions each accepting a single argument.", "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,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.0.8", - "@stdlib/assert-is-positive-integer": "^0.0.7", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/bench": "^0.0.12", - "@stdlib/math-base-special-pow": "^0.0.7", - "@stdlib/random-base-randu": "^0.0.8", - "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..8e7faaf --- /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 b34eaef..0000000 --- a/test/test.js +++ /dev/null @@ -1,291 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var curryRight = require( './../lib' ); - - -// FUNCTIONS // - -function add( x, y, z ) { - return x + y + z; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof curryRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (1 arg)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (2 args; context)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an arity argument which is not a positive integer (3 args)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - 0, - -1, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( add, value, {} ); - }; - } -}); - -tape( 'the function returns a function', function test( t ) { - var fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function curries a function', function test( t) { - var fcn; - var f; - - fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'for each invocation where the invocation number is less than the arity, the curried function returns a new partially applied curry function', function test( t ) { - var sum; - var f0; - var f1; - var f2; - - // Initial curried function has no partially applied arguments... - f0 = curryRight( add ); - - sum = f0( 1 )( 2 )( 3 ); - t.strictEqual( sum, 6, 'returns 6' ); - - sum = f0( 1 )( 3 )( 5 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f0( 10 )( 20 )( 40 ); - t.strictEqual( sum, 70, 'returns 70' ); - - // If arity greater than 1, first invocation returns a curried function with one partially applied argument... - f1 = f0( 2 ); - - sum = f1( 3 )( 4 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f1( 10 )( 20 ); - t.strictEqual( sum, 32, 'returns 32' ); - - sum = f1( -1 )( -2 ); - t.strictEqual( sum, -1, 'returns -1' ); - - // If arity greater than 2, second invocation returns a curried function with two partially applied arguments... - f2 = f1( 3 ); - - sum = f2( 5 ); - t.strictEqual( sum, 10, 'returns 10' ); - - sum = f2( 6 ); - t.strictEqual( sum, 11, 'returns 11' ); - - sum = f2( 10 ); - t.strictEqual( sum, 15, 'returns 15' ); - - // And so on and so forth... - - t.end(); -}); - -tape( 'the function supports specifying a function arity', function test( t ) { - var fcn; - var f; - - function add() { - return arguments[ 0 ] + arguments[ 1 ] + arguments[ 2 ]; - } - - fcn = curryRight( add, 3 ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'the function supports specifying a function context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate( length, units, type, color ) { - return this.style+': '+length+units+' '+type+' '+color; - } - }; - - fcn = curryRight( context.generate, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); - -tape( 'the function supports specifying a function arity and context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate() { - return this.style+': '+arguments[0]+arguments[1]+' '+arguments[2]+' '+arguments[3]; - } - }; - - fcn = curryRight( context.generate, 4, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); From 6950d0733eaf276cf09f2bd956cf04fc3dfddf2c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Apr 2023 05:46:19 +0000 Subject: [PATCH 041/140] Transform error messages --- lib/main.js | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/main.js b/lib/main.js index 8d7768e..6eebd6a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -52,7 +52,7 @@ function curryRight( fcn, arity, thisArg ) { var context; var len; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0j23p', fcn ) ); } if ( arguments.length < 2 ) { len = fcn.length; @@ -63,7 +63,7 @@ function curryRight( fcn, arity, thisArg ) { len = arity; context = thisArg; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) ); + throw new TypeError( format( '0j2Bi', len ) ); } } else if ( isPositiveInteger( arity ) ) { len = arity; diff --git a/package.json b/package.json index 2736773..754a6c6 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-function": "^0.0.8", "@stdlib/assert-is-positive-integer": "^0.0.7", - "@stdlib/string-format": "^0.0.3" + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/bench": "^0.0.12", From 6ddbb355b06cda925945d30237116e52e1cf0a31 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Apr 2023 12:13:23 +0000 Subject: [PATCH 042/140] Remove files --- index.d.ts | 82 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6264 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 689a825..0000000 --- a/index.d.ts +++ /dev/null @@ -1,82 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Curry function. -* -* @param v - curried function parameter -* @returns partially applied curry function or curried function result -*/ -type Closure = ( v: any ) => any; - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param arity - number of parameters -* @param thisArg - evaluation context -* @throws `arity` must be a positive integer -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight( fcn: Function, arity: number, thisArg?: any ): Closure; // tslint-disable-line max-line-length - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param thisArg - evaluation context -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight( fcn: Function, thisArg?: any ): Closure; - - -// EXPORTS // - -export = curryRight; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index a30aaa4..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,i,s){var o,a;if(!e(n))throw new TypeError(r("0j23p",n));if(arguments.length<2){if(a=n.length,!t(a))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",a))}else if(arguments.length>2){if(o=s,!t(a=i))throw new TypeError(r("0j2Bi",a))}else if(t(i))a=i;else{if(a=n.length,!t(a))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",a));o=i}return l([]);function l(e){return function(t){var r=e.slice();if(r.unshift(t),r.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '0j2Bi', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","v","cargs","slice","unshift","apply"],"mappings":";;oSAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,SAE3H,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAEjC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,IAEjID,EAAUF,CACV,CACD,OAAOU,EAAe,IAStB,SAASA,EAAeC,GACvB,OASA,SAAkBC,GACjB,IAAIC,EAAQF,EAAKG,QAEjB,GADAD,EAAME,QAASH,GACVC,EAAML,OAASL,EACnB,OAAOO,EAAeG,GAEvB,OAAOd,EAAIiB,MAAOd,EAASW,EAC3B,CACD,CACF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 8e7faaf..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From c97b1b8e5654d8cfdd786a78e4c240d25115e923 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Apr 2023 12:14:35 +0000 Subject: [PATCH 043/140] 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 | 39 +- benchmark/benchmark.js | 90 - branches.md | 53 - docs/repl.txt | 53 - docs/types/test.ts | 44 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 110 - package.json | 55 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 291 - 37 files changed, 6200 insertions(+), 3881 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 1f7eab5..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-04-01T03:53:01.983Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2b7fad0..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/curry-right) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 26300c3..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/curry-right) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 b01c884..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: '6 18 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 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 + + ```
@@ -247,7 +240,7 @@ console.log( out ); ## 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]. @@ -309,11 +302,11 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry +[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry/tree/esm -[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry +[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry/tree/esm -[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right +[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index fbb976c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isFunction = require( '@stdlib/assert-is-function' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var curryRight = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = curryRight( pow ); - if ( typeof out !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( out ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::returned_function', function benchmark( b ) { - var fcn; - var out; - var i; - - fcn = curryRight( pow ); - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = fcn( randu() )( randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::direct', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = pow( randu(), randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1f7cde2..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/curry-right" -%% click B href "https://github.com/stdlib-js/utils-curry-right/tree/main" -%% click C href "https://github.com/stdlib-js/utils-curry-right/tree/production" -%% click D href "https://github.com/stdlib-js/utils-curry-right/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-curry-right/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-curry-right/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/curry-right -[production-url]: https://github.com/stdlib-js/utils-curry-right/tree/production -[deno-url]: https://github.com/stdlib-js/utils-curry-right/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-curry-right/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-curry-right/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7271aed..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,53 +0,0 @@ - -{{alias}}( fcn[, arity][, thisArg] ) - Transforms a function into a sequence of functions each accepting a single - argument. - - Until return value resolution, each invocation returns a new partially - applied curry function. - - This function applies arguments starting from the right. - - Parameters - ---------- - fcn: Function - Function to curry. - - arity: integer (optional) - Number of parameters. Default: `fcn.length`. - - thisArg: any (optional) - Evaluation context. - - Returns - ------- - out: Function - Curry function. - - Examples - -------- - > function add( x, y ) { return x + y; }; - > var f = {{alias}}( add ); - > var sum = f( 2 )( 3 ) - 5 - - // Supply arity: - > function add() { return arguments[ 0 ] + arguments[ 1 ]; }; - > f = {{alias}}( add, 2 ); - > sum = f( 2 )( 3 ) - 5 - - // Provide function context: - > var obj = { - ... 'name': 'Ada', - ... 'greet': function greet( word1, word2 ) { - ... return word1 + ' ' + word2 + ', ' + this.name + '!' - ... } - ... }; - > f = {{alias}}( obj.greet, obj ); - > var str = f( 'there' )( 'Hello' ) - 'Hello there, Ada!' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a3b29c4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import curryRight = require( './index' ); - - -// TESTS // - -// The function returns a function... -{ - curryRight( ( x: number, y: number ): number => x + y ); // $ExpectType Closure - curryRight( ( x: number, y: number ): number => x + y, 2 ); // $ExpectType Closure - curryRight( ( x: number, y: number ): number => x + y, 2, {} ); // $ExpectType Closure -} - -// The compiler throws an error if the function is provided a first argument other than a function... -{ - curryRight( true ); // $ExpectError - curryRight( false ); // $ExpectError - curryRight( 5 ); // $ExpectError - curryRight( [] ); // $ExpectError - curryRight( {} ); // $ExpectError - curryRight( 'abc' ); // $ExpectError -} - -// The compiler throws an error if the function is provided more than three arguments... -{ - curryRight( ( x: number, y: number ): number => x + y, 2, {}, 4 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 76818ec..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 curryRight = require( './../lib' ); - -var fcn; -var out; -var i; - -function add( x, y, z, w, t, s ) { - return x + y + z + w + t + s; -} - -fcn = curryRight( add ); -out = fcn; -for ( i = 0; i < add.length; i++ ) { - out = out( i*10 ); -} -console.log( out ); 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..a30aaa4 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,i,s){var o,a;if(!e(n))throw new TypeError(r("0j23p",n));if(arguments.length<2){if(a=n.length,!t(a))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",a))}else if(arguments.length>2){if(o=s,!t(a=i))throw new TypeError(r("0j2Bi",a))}else if(t(i))a=i;else{if(a=n.length,!t(a))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",a));o=i}return l([]);function l(e){return function(t){var r=e.slice();if(r.unshift(t),r.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '0j2Bi', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","v","cargs","slice","unshift","apply"],"mappings":";;oSAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,SAE3H,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAEjC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,IAEjID,EAAUF,CACV,CACD,OAAOU,EAAe,IAStB,SAASA,EAAeC,GACvB,OASA,SAAkBC,GACjB,IAAIC,EAAQF,EAAKG,QAEjB,GADAD,EAAME,QAASH,GACVC,EAAML,OAASL,EACnB,OAAOO,EAAeG,GAEvB,OAAOd,EAAIiB,MAAOd,EAASW,EAC3B,CACD,CACF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 7e7d2e8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform a function into a sequence of functions each accepting a single argument. -* -* @module @stdlib/utils-curry-right -* -* @example -* var curryRight = require( '@stdlib/utils-curry-right' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ - -// 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 6eebd6a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* @param {Function} fcn - function to curry -* @param {PositiveInteger} [arity=fcn.length] - number of parameters -* @param {*} [thisArg] - evaluation context -* @throws {TypeError} first argument must be a function -* @throws {TypeError} first argument must be a function having at least one parameter -* @throws {TypeError} `arity` argument must be a positive integer -* @returns {Function} curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -function curryRight( fcn, arity, thisArg ) { - var context; - var len; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0j23p', fcn ) ); - } - if ( arguments.length < 2 ) { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); - } - } else if ( arguments.length > 2 ) { - len = arity; - context = thisArg; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '0j2Bi', len ) ); - } - } else if ( isPositiveInteger( arity ) ) { - len = arity; - } else { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); - } - context = arity; - } - return createCurried( [] ); - - /** - * Returns a curry function. - * - * @private - * @param {Array} args - arguments - * @returns {Function} curry function - */ - function createCurried( args ) { - return curried; - - /** - * Curry function. - * - * @private - * @param {*} v - curried function parameter - * @returns {(Function|*)} partially applied curry function or curried function result - */ - function curried( v ) { - var cargs = args.slice(); - cargs.unshift( v ); - if ( cargs.length < len ) { - return createCurried( cargs ); - } - return fcn.apply( context, cargs ); - } - } -} - - -// EXPORTS // - -module.exports = curryRight; diff --git a/package.json b/package.json index 754a6c6..b53b05c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Transform a function into a sequence of functions each accepting a single argument.", "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,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.0.8", - "@stdlib/assert-is-positive-integer": "^0.0.7", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/bench": "^0.0.12", - "@stdlib/math-base-special-pow": "^0.0.7", - "@stdlib/random-base-randu": "^0.0.8", - "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..596126c --- /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 b34eaef..0000000 --- a/test/test.js +++ /dev/null @@ -1,291 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var curryRight = require( './../lib' ); - - -// FUNCTIONS // - -function add( x, y, z ) { - return x + y + z; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof curryRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (1 arg)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (2 args; context)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an arity argument which is not a positive integer (3 args)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - 0, - -1, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( add, value, {} ); - }; - } -}); - -tape( 'the function returns a function', function test( t ) { - var fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function curries a function', function test( t) { - var fcn; - var f; - - fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'for each invocation where the invocation number is less than the arity, the curried function returns a new partially applied curry function', function test( t ) { - var sum; - var f0; - var f1; - var f2; - - // Initial curried function has no partially applied arguments... - f0 = curryRight( add ); - - sum = f0( 1 )( 2 )( 3 ); - t.strictEqual( sum, 6, 'returns 6' ); - - sum = f0( 1 )( 3 )( 5 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f0( 10 )( 20 )( 40 ); - t.strictEqual( sum, 70, 'returns 70' ); - - // If arity greater than 1, first invocation returns a curried function with one partially applied argument... - f1 = f0( 2 ); - - sum = f1( 3 )( 4 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f1( 10 )( 20 ); - t.strictEqual( sum, 32, 'returns 32' ); - - sum = f1( -1 )( -2 ); - t.strictEqual( sum, -1, 'returns -1' ); - - // If arity greater than 2, second invocation returns a curried function with two partially applied arguments... - f2 = f1( 3 ); - - sum = f2( 5 ); - t.strictEqual( sum, 10, 'returns 10' ); - - sum = f2( 6 ); - t.strictEqual( sum, 11, 'returns 11' ); - - sum = f2( 10 ); - t.strictEqual( sum, 15, 'returns 15' ); - - // And so on and so forth... - - t.end(); -}); - -tape( 'the function supports specifying a function arity', function test( t ) { - var fcn; - var f; - - function add() { - return arguments[ 0 ] + arguments[ 1 ] + arguments[ 2 ]; - } - - fcn = curryRight( add, 3 ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'the function supports specifying a function context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate( length, units, type, color ) { - return this.style+': '+length+units+' '+type+' '+color; - } - }; - - fcn = curryRight( context.generate, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); - -tape( 'the function supports specifying a function arity and context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate() { - return this.style+': '+arguments[0]+arguments[1]+' '+arguments[2]+' '+arguments[3]; - } - }; - - fcn = curryRight( context.generate, 4, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); From 1c9712a67f4b061ebf250194c2acd44eb1fc3d61 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 May 2023 05:32:25 +0000 Subject: [PATCH 044/140] Transform error messages --- lib/main.js | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/main.js b/lib/main.js index 8d7768e..6eebd6a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -52,7 +52,7 @@ function curryRight( fcn, arity, thisArg ) { var context; var len; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0j23p', fcn ) ); } if ( arguments.length < 2 ) { len = fcn.length; @@ -63,7 +63,7 @@ function curryRight( fcn, arity, thisArg ) { len = arity; context = thisArg; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) ); + throw new TypeError( format( '0j2Bi', len ) ); } } else if ( isPositiveInteger( arity ) ) { len = arity; diff --git a/package.json b/package.json index 2736773..754a6c6 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-function": "^0.0.8", "@stdlib/assert-is-positive-integer": "^0.0.7", - "@stdlib/string-format": "^0.0.3" + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/bench": "^0.0.12", From 973b3a390e5cd16684774712857a021283dd7752 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 May 2023 11:59:14 +0000 Subject: [PATCH 045/140] Remove files --- index.d.ts | 82 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6264 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 689a825..0000000 --- a/index.d.ts +++ /dev/null @@ -1,82 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Curry function. -* -* @param v - curried function parameter -* @returns partially applied curry function or curried function result -*/ -type Closure = ( v: any ) => any; - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param arity - number of parameters -* @param thisArg - evaluation context -* @throws `arity` must be a positive integer -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight( fcn: Function, arity: number, thisArg?: any ): Closure; // tslint-disable-line max-line-length - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param thisArg - evaluation context -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight( fcn: Function, thisArg?: any ): Closure; - - -// EXPORTS // - -export = curryRight; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index a30aaa4..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,i,s){var o,a;if(!e(n))throw new TypeError(r("0j23p",n));if(arguments.length<2){if(a=n.length,!t(a))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",a))}else if(arguments.length>2){if(o=s,!t(a=i))throw new TypeError(r("0j2Bi",a))}else if(t(i))a=i;else{if(a=n.length,!t(a))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",a));o=i}return l([]);function l(e){return function(t){var r=e.slice();if(r.unshift(t),r.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '0j2Bi', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","v","cargs","slice","unshift","apply"],"mappings":";;oSAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,SAE3H,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAEjC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,IAEjID,EAAUF,CACV,CACD,OAAOU,EAAe,IAStB,SAASA,EAAeC,GACvB,OASA,SAAkBC,GACjB,IAAIC,EAAQF,EAAKG,QAEjB,GADAD,EAAME,QAASH,GACVC,EAAML,OAASL,EACnB,OAAOO,EAAeG,GAEvB,OAAOd,EAAIiB,MAAOd,EAASW,EAC3B,CACD,CACF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 596126c..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From c54fdcebc385f51b6cf3c3e6fdc18dd40c26e23e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 May 2023 12:00:16 +0000 Subject: [PATCH 046/140] 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 | 39 +- benchmark/benchmark.js | 90 - branches.md | 53 - docs/repl.txt | 53 - docs/types/test.ts | 44 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 110 - package.json | 55 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 291 - 37 files changed, 6200 insertions(+), 3881 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 4d2f4f1..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-05-01T03:41:45.126Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2b7fad0..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/curry-right) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 26300c3..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/curry-right) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 b01c884..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: '6 18 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 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 + + ```
@@ -247,7 +240,7 @@ console.log( out ); ## 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]. @@ -309,11 +302,11 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry +[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry/tree/esm -[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry +[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry/tree/esm -[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right +[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index fbb976c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isFunction = require( '@stdlib/assert-is-function' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var curryRight = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = curryRight( pow ); - if ( typeof out !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( out ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::returned_function', function benchmark( b ) { - var fcn; - var out; - var i; - - fcn = curryRight( pow ); - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = fcn( randu() )( randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::direct', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = pow( randu(), randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1f7cde2..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/curry-right" -%% click B href "https://github.com/stdlib-js/utils-curry-right/tree/main" -%% click C href "https://github.com/stdlib-js/utils-curry-right/tree/production" -%% click D href "https://github.com/stdlib-js/utils-curry-right/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-curry-right/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-curry-right/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/curry-right -[production-url]: https://github.com/stdlib-js/utils-curry-right/tree/production -[deno-url]: https://github.com/stdlib-js/utils-curry-right/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-curry-right/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-curry-right/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7271aed..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,53 +0,0 @@ - -{{alias}}( fcn[, arity][, thisArg] ) - Transforms a function into a sequence of functions each accepting a single - argument. - - Until return value resolution, each invocation returns a new partially - applied curry function. - - This function applies arguments starting from the right. - - Parameters - ---------- - fcn: Function - Function to curry. - - arity: integer (optional) - Number of parameters. Default: `fcn.length`. - - thisArg: any (optional) - Evaluation context. - - Returns - ------- - out: Function - Curry function. - - Examples - -------- - > function add( x, y ) { return x + y; }; - > var f = {{alias}}( add ); - > var sum = f( 2 )( 3 ) - 5 - - // Supply arity: - > function add() { return arguments[ 0 ] + arguments[ 1 ]; }; - > f = {{alias}}( add, 2 ); - > sum = f( 2 )( 3 ) - 5 - - // Provide function context: - > var obj = { - ... 'name': 'Ada', - ... 'greet': function greet( word1, word2 ) { - ... return word1 + ' ' + word2 + ', ' + this.name + '!' - ... } - ... }; - > f = {{alias}}( obj.greet, obj ); - > var str = f( 'there' )( 'Hello' ) - 'Hello there, Ada!' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a3b29c4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import curryRight = require( './index' ); - - -// TESTS // - -// The function returns a function... -{ - curryRight( ( x: number, y: number ): number => x + y ); // $ExpectType Closure - curryRight( ( x: number, y: number ): number => x + y, 2 ); // $ExpectType Closure - curryRight( ( x: number, y: number ): number => x + y, 2, {} ); // $ExpectType Closure -} - -// The compiler throws an error if the function is provided a first argument other than a function... -{ - curryRight( true ); // $ExpectError - curryRight( false ); // $ExpectError - curryRight( 5 ); // $ExpectError - curryRight( [] ); // $ExpectError - curryRight( {} ); // $ExpectError - curryRight( 'abc' ); // $ExpectError -} - -// The compiler throws an error if the function is provided more than three arguments... -{ - curryRight( ( x: number, y: number ): number => x + y, 2, {}, 4 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 76818ec..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 curryRight = require( './../lib' ); - -var fcn; -var out; -var i; - -function add( x, y, z, w, t, s ) { - return x + y + z + w + t + s; -} - -fcn = curryRight( add ); -out = fcn; -for ( i = 0; i < add.length; i++ ) { - out = out( i*10 ); -} -console.log( out ); 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..a30aaa4 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,i,s){var o,a;if(!e(n))throw new TypeError(r("0j23p",n));if(arguments.length<2){if(a=n.length,!t(a))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",a))}else if(arguments.length>2){if(o=s,!t(a=i))throw new TypeError(r("0j2Bi",a))}else if(t(i))a=i;else{if(a=n.length,!t(a))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",a));o=i}return l([]);function l(e){return function(t){var r=e.slice();if(r.unshift(t),r.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '0j2Bi', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","v","cargs","slice","unshift","apply"],"mappings":";;oSAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,SAE3H,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAEjC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,IAEjID,EAAUF,CACV,CACD,OAAOU,EAAe,IAStB,SAASA,EAAeC,GACvB,OASA,SAAkBC,GACjB,IAAIC,EAAQF,EAAKG,QAEjB,GADAD,EAAME,QAASH,GACVC,EAAML,OAASL,EACnB,OAAOO,EAAeG,GAEvB,OAAOd,EAAIiB,MAAOd,EAASW,EAC3B,CACD,CACF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 7e7d2e8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform a function into a sequence of functions each accepting a single argument. -* -* @module @stdlib/utils-curry-right -* -* @example -* var curryRight = require( '@stdlib/utils-curry-right' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ - -// 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 6eebd6a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* @param {Function} fcn - function to curry -* @param {PositiveInteger} [arity=fcn.length] - number of parameters -* @param {*} [thisArg] - evaluation context -* @throws {TypeError} first argument must be a function -* @throws {TypeError} first argument must be a function having at least one parameter -* @throws {TypeError} `arity` argument must be a positive integer -* @returns {Function} curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -function curryRight( fcn, arity, thisArg ) { - var context; - var len; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0j23p', fcn ) ); - } - if ( arguments.length < 2 ) { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); - } - } else if ( arguments.length > 2 ) { - len = arity; - context = thisArg; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '0j2Bi', len ) ); - } - } else if ( isPositiveInteger( arity ) ) { - len = arity; - } else { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); - } - context = arity; - } - return createCurried( [] ); - - /** - * Returns a curry function. - * - * @private - * @param {Array} args - arguments - * @returns {Function} curry function - */ - function createCurried( args ) { - return curried; - - /** - * Curry function. - * - * @private - * @param {*} v - curried function parameter - * @returns {(Function|*)} partially applied curry function or curried function result - */ - function curried( v ) { - var cargs = args.slice(); - cargs.unshift( v ); - if ( cargs.length < len ) { - return createCurried( cargs ); - } - return fcn.apply( context, cargs ); - } - } -} - - -// EXPORTS // - -module.exports = curryRight; diff --git a/package.json b/package.json index 754a6c6..b53b05c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Transform a function into a sequence of functions each accepting a single argument.", "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,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.0.8", - "@stdlib/assert-is-positive-integer": "^0.0.7", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/bench": "^0.0.12", - "@stdlib/math-base-special-pow": "^0.0.7", - "@stdlib/random-base-randu": "^0.0.8", - "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..e0d9450 --- /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 b34eaef..0000000 --- a/test/test.js +++ /dev/null @@ -1,291 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var curryRight = require( './../lib' ); - - -// FUNCTIONS // - -function add( x, y, z ) { - return x + y + z; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof curryRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (1 arg)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (2 args; context)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an arity argument which is not a positive integer (3 args)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - 0, - -1, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( add, value, {} ); - }; - } -}); - -tape( 'the function returns a function', function test( t ) { - var fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function curries a function', function test( t) { - var fcn; - var f; - - fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'for each invocation where the invocation number is less than the arity, the curried function returns a new partially applied curry function', function test( t ) { - var sum; - var f0; - var f1; - var f2; - - // Initial curried function has no partially applied arguments... - f0 = curryRight( add ); - - sum = f0( 1 )( 2 )( 3 ); - t.strictEqual( sum, 6, 'returns 6' ); - - sum = f0( 1 )( 3 )( 5 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f0( 10 )( 20 )( 40 ); - t.strictEqual( sum, 70, 'returns 70' ); - - // If arity greater than 1, first invocation returns a curried function with one partially applied argument... - f1 = f0( 2 ); - - sum = f1( 3 )( 4 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f1( 10 )( 20 ); - t.strictEqual( sum, 32, 'returns 32' ); - - sum = f1( -1 )( -2 ); - t.strictEqual( sum, -1, 'returns -1' ); - - // If arity greater than 2, second invocation returns a curried function with two partially applied arguments... - f2 = f1( 3 ); - - sum = f2( 5 ); - t.strictEqual( sum, 10, 'returns 10' ); - - sum = f2( 6 ); - t.strictEqual( sum, 11, 'returns 11' ); - - sum = f2( 10 ); - t.strictEqual( sum, 15, 'returns 15' ); - - // And so on and so forth... - - t.end(); -}); - -tape( 'the function supports specifying a function arity', function test( t ) { - var fcn; - var f; - - function add() { - return arguments[ 0 ] + arguments[ 1 ] + arguments[ 2 ]; - } - - fcn = curryRight( add, 3 ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'the function supports specifying a function context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate( length, units, type, color ) { - return this.style+': '+length+units+' '+type+' '+color; - } - }; - - fcn = curryRight( context.generate, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); - -tape( 'the function supports specifying a function arity and context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate() { - return this.style+': '+arguments[0]+arguments[1]+' '+arguments[2]+' '+arguments[3]; - } - }; - - fcn = curryRight( context.generate, 4, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); From 1efb3c199bc7ea641a36dfd9ce6b498e06823a89 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Jun 2023 05:16:36 +0000 Subject: [PATCH 047/140] Transform error messages --- lib/main.js | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/main.js b/lib/main.js index 8d7768e..6eebd6a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -52,7 +52,7 @@ function curryRight( fcn, arity, thisArg ) { var context; var len; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0j23p', fcn ) ); } if ( arguments.length < 2 ) { len = fcn.length; @@ -63,7 +63,7 @@ function curryRight( fcn, arity, thisArg ) { len = arity; context = thisArg; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) ); + throw new TypeError( format( '0j2Bi', len ) ); } } else if ( isPositiveInteger( arity ) ) { len = arity; diff --git a/package.json b/package.json index 2736773..754a6c6 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-function": "^0.0.8", "@stdlib/assert-is-positive-integer": "^0.0.7", - "@stdlib/string-format": "^0.0.3" + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/bench": "^0.0.12", From edd783b014deca3723706a0006a97f717fb0b4a8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Jun 2023 12:26:45 +0000 Subject: [PATCH 048/140] Remove files --- index.d.ts | 82 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6264 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 689a825..0000000 --- a/index.d.ts +++ /dev/null @@ -1,82 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Curry function. -* -* @param v - curried function parameter -* @returns partially applied curry function or curried function result -*/ -type Closure = ( v: any ) => any; - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param arity - number of parameters -* @param thisArg - evaluation context -* @throws `arity` must be a positive integer -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight( fcn: Function, arity: number, thisArg?: any ): Closure; // tslint-disable-line max-line-length - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param thisArg - evaluation context -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight( fcn: Function, thisArg?: any ): Closure; - - -// EXPORTS // - -export = curryRight; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index a30aaa4..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,i,s){var o,a;if(!e(n))throw new TypeError(r("0j23p",n));if(arguments.length<2){if(a=n.length,!t(a))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",a))}else if(arguments.length>2){if(o=s,!t(a=i))throw new TypeError(r("0j2Bi",a))}else if(t(i))a=i;else{if(a=n.length,!t(a))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",a));o=i}return l([]);function l(e){return function(t){var r=e.slice();if(r.unshift(t),r.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '0j2Bi', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","v","cargs","slice","unshift","apply"],"mappings":";;oSAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,SAE3H,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAEjC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,IAEjID,EAAUF,CACV,CACD,OAAOU,EAAe,IAStB,SAASA,EAAeC,GACvB,OASA,SAAkBC,GACjB,IAAIC,EAAQF,EAAKG,QAEjB,GADAD,EAAME,QAASH,GACVC,EAAML,OAASL,EACnB,OAAOO,EAAeG,GAEvB,OAAOd,EAAIiB,MAAOd,EAASW,EAC3B,CACD,CACF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index e0d9450..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 911c7f0bc94445d2d2e644c9adf1f6b821e872e2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Jun 2023 12:27:37 +0000 Subject: [PATCH 049/140] 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 | 39 +- benchmark/benchmark.js | 90 - branches.md | 53 - docs/repl.txt | 53 - docs/types/test.ts | 44 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 110 - package.json | 55 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 291 - 37 files changed, 6200 insertions(+), 3881 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 1dbed34..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-06-01T03:25:28.582Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2b7fad0..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/curry-right) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 26300c3..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/curry-right) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 b01c884..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: '6 18 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 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 + + ```
@@ -247,7 +240,7 @@ console.log( out ); ## 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]. @@ -309,11 +302,11 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry +[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry/tree/esm -[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry +[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry/tree/esm -[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right +[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index fbb976c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isFunction = require( '@stdlib/assert-is-function' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var curryRight = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = curryRight( pow ); - if ( typeof out !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( out ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::returned_function', function benchmark( b ) { - var fcn; - var out; - var i; - - fcn = curryRight( pow ); - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = fcn( randu() )( randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::direct', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = pow( randu(), randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1f7cde2..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/curry-right" -%% click B href "https://github.com/stdlib-js/utils-curry-right/tree/main" -%% click C href "https://github.com/stdlib-js/utils-curry-right/tree/production" -%% click D href "https://github.com/stdlib-js/utils-curry-right/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-curry-right/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-curry-right/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/curry-right -[production-url]: https://github.com/stdlib-js/utils-curry-right/tree/production -[deno-url]: https://github.com/stdlib-js/utils-curry-right/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-curry-right/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-curry-right/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7271aed..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,53 +0,0 @@ - -{{alias}}( fcn[, arity][, thisArg] ) - Transforms a function into a sequence of functions each accepting a single - argument. - - Until return value resolution, each invocation returns a new partially - applied curry function. - - This function applies arguments starting from the right. - - Parameters - ---------- - fcn: Function - Function to curry. - - arity: integer (optional) - Number of parameters. Default: `fcn.length`. - - thisArg: any (optional) - Evaluation context. - - Returns - ------- - out: Function - Curry function. - - Examples - -------- - > function add( x, y ) { return x + y; }; - > var f = {{alias}}( add ); - > var sum = f( 2 )( 3 ) - 5 - - // Supply arity: - > function add() { return arguments[ 0 ] + arguments[ 1 ]; }; - > f = {{alias}}( add, 2 ); - > sum = f( 2 )( 3 ) - 5 - - // Provide function context: - > var obj = { - ... 'name': 'Ada', - ... 'greet': function greet( word1, word2 ) { - ... return word1 + ' ' + word2 + ', ' + this.name + '!' - ... } - ... }; - > f = {{alias}}( obj.greet, obj ); - > var str = f( 'there' )( 'Hello' ) - 'Hello there, Ada!' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a3b29c4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import curryRight = require( './index' ); - - -// TESTS // - -// The function returns a function... -{ - curryRight( ( x: number, y: number ): number => x + y ); // $ExpectType Closure - curryRight( ( x: number, y: number ): number => x + y, 2 ); // $ExpectType Closure - curryRight( ( x: number, y: number ): number => x + y, 2, {} ); // $ExpectType Closure -} - -// The compiler throws an error if the function is provided a first argument other than a function... -{ - curryRight( true ); // $ExpectError - curryRight( false ); // $ExpectError - curryRight( 5 ); // $ExpectError - curryRight( [] ); // $ExpectError - curryRight( {} ); // $ExpectError - curryRight( 'abc' ); // $ExpectError -} - -// The compiler throws an error if the function is provided more than three arguments... -{ - curryRight( ( x: number, y: number ): number => x + y, 2, {}, 4 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 76818ec..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 curryRight = require( './../lib' ); - -var fcn; -var out; -var i; - -function add( x, y, z, w, t, s ) { - return x + y + z + w + t + s; -} - -fcn = curryRight( add ); -out = fcn; -for ( i = 0; i < add.length; i++ ) { - out = out( i*10 ); -} -console.log( out ); 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..a30aaa4 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,i,s){var o,a;if(!e(n))throw new TypeError(r("0j23p",n));if(arguments.length<2){if(a=n.length,!t(a))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",a))}else if(arguments.length>2){if(o=s,!t(a=i))throw new TypeError(r("0j2Bi",a))}else if(t(i))a=i;else{if(a=n.length,!t(a))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",a));o=i}return l([]);function l(e){return function(t){var r=e.slice();if(r.unshift(t),r.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '0j2Bi', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","v","cargs","slice","unshift","apply"],"mappings":";;oSAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,SAE3H,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAEjC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,IAEjID,EAAUF,CACV,CACD,OAAOU,EAAe,IAStB,SAASA,EAAeC,GACvB,OASA,SAAkBC,GACjB,IAAIC,EAAQF,EAAKG,QAEjB,GADAD,EAAME,QAASH,GACVC,EAAML,OAASL,EACnB,OAAOO,EAAeG,GAEvB,OAAOd,EAAIiB,MAAOd,EAASW,EAC3B,CACD,CACF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 7e7d2e8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform a function into a sequence of functions each accepting a single argument. -* -* @module @stdlib/utils-curry-right -* -* @example -* var curryRight = require( '@stdlib/utils-curry-right' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ - -// 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 6eebd6a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* @param {Function} fcn - function to curry -* @param {PositiveInteger} [arity=fcn.length] - number of parameters -* @param {*} [thisArg] - evaluation context -* @throws {TypeError} first argument must be a function -* @throws {TypeError} first argument must be a function having at least one parameter -* @throws {TypeError} `arity` argument must be a positive integer -* @returns {Function} curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -function curryRight( fcn, arity, thisArg ) { - var context; - var len; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0j23p', fcn ) ); - } - if ( arguments.length < 2 ) { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); - } - } else if ( arguments.length > 2 ) { - len = arity; - context = thisArg; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '0j2Bi', len ) ); - } - } else if ( isPositiveInteger( arity ) ) { - len = arity; - } else { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); - } - context = arity; - } - return createCurried( [] ); - - /** - * Returns a curry function. - * - * @private - * @param {Array} args - arguments - * @returns {Function} curry function - */ - function createCurried( args ) { - return curried; - - /** - * Curry function. - * - * @private - * @param {*} v - curried function parameter - * @returns {(Function|*)} partially applied curry function or curried function result - */ - function curried( v ) { - var cargs = args.slice(); - cargs.unshift( v ); - if ( cargs.length < len ) { - return createCurried( cargs ); - } - return fcn.apply( context, cargs ); - } - } -} - - -// EXPORTS // - -module.exports = curryRight; diff --git a/package.json b/package.json index 754a6c6..b53b05c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Transform a function into a sequence of functions each accepting a single argument.", "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,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.0.8", - "@stdlib/assert-is-positive-integer": "^0.0.7", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/bench": "^0.0.12", - "@stdlib/math-base-special-pow": "^0.0.7", - "@stdlib/random-base-randu": "^0.0.8", - "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..f3cadf0 --- /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 b34eaef..0000000 --- a/test/test.js +++ /dev/null @@ -1,291 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var curryRight = require( './../lib' ); - - -// FUNCTIONS // - -function add( x, y, z ) { - return x + y + z; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof curryRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (1 arg)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (2 args; context)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an arity argument which is not a positive integer (3 args)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - 0, - -1, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( add, value, {} ); - }; - } -}); - -tape( 'the function returns a function', function test( t ) { - var fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function curries a function', function test( t) { - var fcn; - var f; - - fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'for each invocation where the invocation number is less than the arity, the curried function returns a new partially applied curry function', function test( t ) { - var sum; - var f0; - var f1; - var f2; - - // Initial curried function has no partially applied arguments... - f0 = curryRight( add ); - - sum = f0( 1 )( 2 )( 3 ); - t.strictEqual( sum, 6, 'returns 6' ); - - sum = f0( 1 )( 3 )( 5 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f0( 10 )( 20 )( 40 ); - t.strictEqual( sum, 70, 'returns 70' ); - - // If arity greater than 1, first invocation returns a curried function with one partially applied argument... - f1 = f0( 2 ); - - sum = f1( 3 )( 4 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f1( 10 )( 20 ); - t.strictEqual( sum, 32, 'returns 32' ); - - sum = f1( -1 )( -2 ); - t.strictEqual( sum, -1, 'returns -1' ); - - // If arity greater than 2, second invocation returns a curried function with two partially applied arguments... - f2 = f1( 3 ); - - sum = f2( 5 ); - t.strictEqual( sum, 10, 'returns 10' ); - - sum = f2( 6 ); - t.strictEqual( sum, 11, 'returns 11' ); - - sum = f2( 10 ); - t.strictEqual( sum, 15, 'returns 15' ); - - // And so on and so forth... - - t.end(); -}); - -tape( 'the function supports specifying a function arity', function test( t ) { - var fcn; - var f; - - function add() { - return arguments[ 0 ] + arguments[ 1 ] + arguments[ 2 ]; - } - - fcn = curryRight( add, 3 ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'the function supports specifying a function context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate( length, units, type, color ) { - return this.style+': '+length+units+' '+type+' '+color; - } - }; - - fcn = curryRight( context.generate, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); - -tape( 'the function supports specifying a function arity and context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate() { - return this.style+': '+arguments[0]+arguments[1]+' '+arguments[2]+' '+arguments[3]; - } - }; - - fcn = curryRight( context.generate, 4, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); From fdf7840491a604d043a578a65965818e8ac71620 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jul 2023 05:20:22 +0000 Subject: [PATCH 050/140] Transform error messages --- lib/main.js | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/main.js b/lib/main.js index 8d7768e..6eebd6a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -52,7 +52,7 @@ function curryRight( fcn, arity, thisArg ) { var context; var len; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0j23p', fcn ) ); } if ( arguments.length < 2 ) { len = fcn.length; @@ -63,7 +63,7 @@ function curryRight( fcn, arity, thisArg ) { len = arity; context = thisArg; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) ); + throw new TypeError( format( '0j2Bi', len ) ); } } else if ( isPositiveInteger( arity ) ) { len = arity; diff --git a/package.json b/package.json index 2736773..754a6c6 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-function": "^0.0.8", "@stdlib/assert-is-positive-integer": "^0.0.7", - "@stdlib/string-format": "^0.0.3" + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/bench": "^0.0.12", From ba2121bc7887a2ed68900e51d80ae39c7fe5999c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jul 2023 12:39:50 +0000 Subject: [PATCH 051/140] Remove files --- index.d.ts | 82 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6264 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 689a825..0000000 --- a/index.d.ts +++ /dev/null @@ -1,82 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Curry function. -* -* @param v - curried function parameter -* @returns partially applied curry function or curried function result -*/ -type Closure = ( v: any ) => any; - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param arity - number of parameters -* @param thisArg - evaluation context -* @throws `arity` must be a positive integer -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight( fcn: Function, arity: number, thisArg?: any ): Closure; // tslint-disable-line max-line-length - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param thisArg - evaluation context -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight( fcn: Function, thisArg?: any ): Closure; - - -// EXPORTS // - -export = curryRight; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index a30aaa4..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,i,s){var o,a;if(!e(n))throw new TypeError(r("0j23p",n));if(arguments.length<2){if(a=n.length,!t(a))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",a))}else if(arguments.length>2){if(o=s,!t(a=i))throw new TypeError(r("0j2Bi",a))}else if(t(i))a=i;else{if(a=n.length,!t(a))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",a));o=i}return l([]);function l(e){return function(t){var r=e.slice();if(r.unshift(t),r.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '0j2Bi', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","v","cargs","slice","unshift","apply"],"mappings":";;oSAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,SAE3H,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAEjC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,IAEjID,EAAUF,CACV,CACD,OAAOU,EAAe,IAStB,SAASA,EAAeC,GACvB,OASA,SAAkBC,GACjB,IAAIC,EAAQF,EAAKG,QAEjB,GADAD,EAAME,QAASH,GACVC,EAAML,OAASL,EACnB,OAAOO,EAAeG,GAEvB,OAAOd,EAAIiB,MAAOd,EAASW,EAC3B,CACD,CACF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index f3cadf0..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 529da9b30715999c60ab73d870062b400ea8f467 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jul 2023 12:40:38 +0000 Subject: [PATCH 052/140] 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 | 39 +- benchmark/benchmark.js | 90 - branches.md | 53 - docs/repl.txt | 53 - docs/types/test.ts | 44 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 110 - package.json | 55 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 291 - 37 files changed, 6200 insertions(+), 3881 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 311a32a..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-07-01T03:26:40.100Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2b7fad0..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/curry-right) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 26300c3..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/curry-right) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 b01c884..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: '6 18 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 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 + + ```
@@ -247,7 +240,7 @@ console.log( out ); ## 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]. @@ -309,11 +302,11 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry +[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry/tree/esm -[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry +[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry/tree/esm -[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right +[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index fbb976c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isFunction = require( '@stdlib/assert-is-function' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var curryRight = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = curryRight( pow ); - if ( typeof out !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( out ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::returned_function', function benchmark( b ) { - var fcn; - var out; - var i; - - fcn = curryRight( pow ); - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = fcn( randu() )( randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::direct', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = pow( randu(), randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1f7cde2..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/curry-right" -%% click B href "https://github.com/stdlib-js/utils-curry-right/tree/main" -%% click C href "https://github.com/stdlib-js/utils-curry-right/tree/production" -%% click D href "https://github.com/stdlib-js/utils-curry-right/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-curry-right/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-curry-right/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/curry-right -[production-url]: https://github.com/stdlib-js/utils-curry-right/tree/production -[deno-url]: https://github.com/stdlib-js/utils-curry-right/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-curry-right/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-curry-right/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7271aed..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,53 +0,0 @@ - -{{alias}}( fcn[, arity][, thisArg] ) - Transforms a function into a sequence of functions each accepting a single - argument. - - Until return value resolution, each invocation returns a new partially - applied curry function. - - This function applies arguments starting from the right. - - Parameters - ---------- - fcn: Function - Function to curry. - - arity: integer (optional) - Number of parameters. Default: `fcn.length`. - - thisArg: any (optional) - Evaluation context. - - Returns - ------- - out: Function - Curry function. - - Examples - -------- - > function add( x, y ) { return x + y; }; - > var f = {{alias}}( add ); - > var sum = f( 2 )( 3 ) - 5 - - // Supply arity: - > function add() { return arguments[ 0 ] + arguments[ 1 ]; }; - > f = {{alias}}( add, 2 ); - > sum = f( 2 )( 3 ) - 5 - - // Provide function context: - > var obj = { - ... 'name': 'Ada', - ... 'greet': function greet( word1, word2 ) { - ... return word1 + ' ' + word2 + ', ' + this.name + '!' - ... } - ... }; - > f = {{alias}}( obj.greet, obj ); - > var str = f( 'there' )( 'Hello' ) - 'Hello there, Ada!' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a3b29c4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import curryRight = require( './index' ); - - -// TESTS // - -// The function returns a function... -{ - curryRight( ( x: number, y: number ): number => x + y ); // $ExpectType Closure - curryRight( ( x: number, y: number ): number => x + y, 2 ); // $ExpectType Closure - curryRight( ( x: number, y: number ): number => x + y, 2, {} ); // $ExpectType Closure -} - -// The compiler throws an error if the function is provided a first argument other than a function... -{ - curryRight( true ); // $ExpectError - curryRight( false ); // $ExpectError - curryRight( 5 ); // $ExpectError - curryRight( [] ); // $ExpectError - curryRight( {} ); // $ExpectError - curryRight( 'abc' ); // $ExpectError -} - -// The compiler throws an error if the function is provided more than three arguments... -{ - curryRight( ( x: number, y: number ): number => x + y, 2, {}, 4 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 76818ec..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 curryRight = require( './../lib' ); - -var fcn; -var out; -var i; - -function add( x, y, z, w, t, s ) { - return x + y + z + w + t + s; -} - -fcn = curryRight( add ); -out = fcn; -for ( i = 0; i < add.length; i++ ) { - out = out( i*10 ); -} -console.log( out ); 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..a30aaa4 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,i,s){var o,a;if(!e(n))throw new TypeError(r("0j23p",n));if(arguments.length<2){if(a=n.length,!t(a))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",a))}else if(arguments.length>2){if(o=s,!t(a=i))throw new TypeError(r("0j2Bi",a))}else if(t(i))a=i;else{if(a=n.length,!t(a))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",a));o=i}return l([]);function l(e){return function(t){var r=e.slice();if(r.unshift(t),r.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '0j2Bi', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","v","cargs","slice","unshift","apply"],"mappings":";;oSAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,SAE3H,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAEjC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,IAEjID,EAAUF,CACV,CACD,OAAOU,EAAe,IAStB,SAASA,EAAeC,GACvB,OASA,SAAkBC,GACjB,IAAIC,EAAQF,EAAKG,QAEjB,GADAD,EAAME,QAASH,GACVC,EAAML,OAASL,EACnB,OAAOO,EAAeG,GAEvB,OAAOd,EAAIiB,MAAOd,EAASW,EAC3B,CACD,CACF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 7e7d2e8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform a function into a sequence of functions each accepting a single argument. -* -* @module @stdlib/utils-curry-right -* -* @example -* var curryRight = require( '@stdlib/utils-curry-right' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ - -// 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 6eebd6a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* @param {Function} fcn - function to curry -* @param {PositiveInteger} [arity=fcn.length] - number of parameters -* @param {*} [thisArg] - evaluation context -* @throws {TypeError} first argument must be a function -* @throws {TypeError} first argument must be a function having at least one parameter -* @throws {TypeError} `arity` argument must be a positive integer -* @returns {Function} curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -function curryRight( fcn, arity, thisArg ) { - var context; - var len; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0j23p', fcn ) ); - } - if ( arguments.length < 2 ) { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); - } - } else if ( arguments.length > 2 ) { - len = arity; - context = thisArg; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '0j2Bi', len ) ); - } - } else if ( isPositiveInteger( arity ) ) { - len = arity; - } else { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); - } - context = arity; - } - return createCurried( [] ); - - /** - * Returns a curry function. - * - * @private - * @param {Array} args - arguments - * @returns {Function} curry function - */ - function createCurried( args ) { - return curried; - - /** - * Curry function. - * - * @private - * @param {*} v - curried function parameter - * @returns {(Function|*)} partially applied curry function or curried function result - */ - function curried( v ) { - var cargs = args.slice(); - cargs.unshift( v ); - if ( cargs.length < len ) { - return createCurried( cargs ); - } - return fcn.apply( context, cargs ); - } - } -} - - -// EXPORTS // - -module.exports = curryRight; diff --git a/package.json b/package.json index 754a6c6..b53b05c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Transform a function into a sequence of functions each accepting a single argument.", "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,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.0.8", - "@stdlib/assert-is-positive-integer": "^0.0.7", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/bench": "^0.0.12", - "@stdlib/math-base-special-pow": "^0.0.7", - "@stdlib/random-base-randu": "^0.0.8", - "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..fabdfc1 --- /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 b34eaef..0000000 --- a/test/test.js +++ /dev/null @@ -1,291 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var curryRight = require( './../lib' ); - - -// FUNCTIONS // - -function add( x, y, z ) { - return x + y + z; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof curryRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (1 arg)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (2 args; context)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an arity argument which is not a positive integer (3 args)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - 0, - -1, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( add, value, {} ); - }; - } -}); - -tape( 'the function returns a function', function test( t ) { - var fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function curries a function', function test( t) { - var fcn; - var f; - - fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'for each invocation where the invocation number is less than the arity, the curried function returns a new partially applied curry function', function test( t ) { - var sum; - var f0; - var f1; - var f2; - - // Initial curried function has no partially applied arguments... - f0 = curryRight( add ); - - sum = f0( 1 )( 2 )( 3 ); - t.strictEqual( sum, 6, 'returns 6' ); - - sum = f0( 1 )( 3 )( 5 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f0( 10 )( 20 )( 40 ); - t.strictEqual( sum, 70, 'returns 70' ); - - // If arity greater than 1, first invocation returns a curried function with one partially applied argument... - f1 = f0( 2 ); - - sum = f1( 3 )( 4 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f1( 10 )( 20 ); - t.strictEqual( sum, 32, 'returns 32' ); - - sum = f1( -1 )( -2 ); - t.strictEqual( sum, -1, 'returns -1' ); - - // If arity greater than 2, second invocation returns a curried function with two partially applied arguments... - f2 = f1( 3 ); - - sum = f2( 5 ); - t.strictEqual( sum, 10, 'returns 10' ); - - sum = f2( 6 ); - t.strictEqual( sum, 11, 'returns 11' ); - - sum = f2( 10 ); - t.strictEqual( sum, 15, 'returns 15' ); - - // And so on and so forth... - - t.end(); -}); - -tape( 'the function supports specifying a function arity', function test( t ) { - var fcn; - var f; - - function add() { - return arguments[ 0 ] + arguments[ 1 ] + arguments[ 2 ]; - } - - fcn = curryRight( add, 3 ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'the function supports specifying a function context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate( length, units, type, color ) { - return this.style+': '+length+units+' '+type+' '+color; - } - }; - - fcn = curryRight( context.generate, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); - -tape( 'the function supports specifying a function arity and context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate() { - return this.style+': '+arguments[0]+arguments[1]+' '+arguments[2]+' '+arguments[3]; - } - }; - - fcn = curryRight( context.generate, 4, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); From 5f73dab8b3623a60093deb39cbeed1bc2164b29e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Aug 2023 05:44:40 +0000 Subject: [PATCH 053/140] Transform error messages --- lib/main.js | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/main.js b/lib/main.js index 8d7768e..6eebd6a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -52,7 +52,7 @@ function curryRight( fcn, arity, thisArg ) { var context; var len; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '0j23p', fcn ) ); } if ( arguments.length < 2 ) { len = fcn.length; @@ -63,7 +63,7 @@ function curryRight( fcn, arity, thisArg ) { len = arity; context = thisArg; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) ); + throw new TypeError( format( '0j2Bi', len ) ); } } else if ( isPositiveInteger( arity ) ) { len = arity; diff --git a/package.json b/package.json index 2736773..754a6c6 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-function": "^0.0.8", "@stdlib/assert-is-positive-integer": "^0.0.7", - "@stdlib/string-format": "^0.0.3" + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/bench": "^0.0.12", From 5e9cba31a0a7db6a27fdab796e357faef2afaf25 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Aug 2023 13:17:39 +0000 Subject: [PATCH 054/140] Remove files --- index.d.ts | 82 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6264 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 689a825..0000000 --- a/index.d.ts +++ /dev/null @@ -1,82 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Curry function. -* -* @param v - curried function parameter -* @returns partially applied curry function or curried function result -*/ -type Closure = ( v: any ) => any; - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param arity - number of parameters -* @param thisArg - evaluation context -* @throws `arity` must be a positive integer -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight( fcn: Function, arity: number, thisArg?: any ): Closure; // tslint-disable-line max-line-length - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param thisArg - evaluation context -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight( fcn: Function, thisArg?: any ): Closure; - - -// EXPORTS // - -export = curryRight; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index a30aaa4..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,i,s){var o,a;if(!e(n))throw new TypeError(r("0j23p",n));if(arguments.length<2){if(a=n.length,!t(a))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",a))}else if(arguments.length>2){if(o=s,!t(a=i))throw new TypeError(r("0j2Bi",a))}else if(t(i))a=i;else{if(a=n.length,!t(a))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",a));o=i}return l([]);function l(e){return function(t){var r=e.slice();if(r.unshift(t),r.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '0j2Bi', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","v","cargs","slice","unshift","apply"],"mappings":";;oSAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,SAE3H,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAEjC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,IAEjID,EAAUF,CACV,CACD,OAAOU,EAAe,IAStB,SAASA,EAAeC,GACvB,OASA,SAAkBC,GACjB,IAAIC,EAAQF,EAAKG,QAEjB,GADAD,EAAME,QAASH,GACVC,EAAML,OAASL,EACnB,OAAOO,EAAeG,GAEvB,OAAOd,EAAIiB,MAAOd,EAASW,EAC3B,CACD,CACF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index fabdfc1..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From a86331e6c67d92a6400150cba59e77aba81bbd80 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Aug 2023 13:18:32 +0000 Subject: [PATCH 055/140] 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 | 39 +- benchmark/benchmark.js | 90 - branches.md | 53 - docs/repl.txt | 53 - docs/types/test.ts | 44 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 110 - package.json | 55 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 291 - 37 files changed, 6200 insertions(+), 3881 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 97a545d..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-08-01T03:45:48.486Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2b7fad0..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/curry-right) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 26300c3..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/curry-right) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 b01c884..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: '6 18 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 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 + + ```
@@ -247,7 +240,7 @@ console.log( out ); ## 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]. @@ -309,11 +302,11 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry +[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry/tree/esm -[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry +[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry/tree/esm -[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right +[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index fbb976c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isFunction = require( '@stdlib/assert-is-function' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var curryRight = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = curryRight( pow ); - if ( typeof out !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( out ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::returned_function', function benchmark( b ) { - var fcn; - var out; - var i; - - fcn = curryRight( pow ); - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = fcn( randu() )( randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::direct', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = pow( randu(), randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1f7cde2..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/curry-right" -%% click B href "https://github.com/stdlib-js/utils-curry-right/tree/main" -%% click C href "https://github.com/stdlib-js/utils-curry-right/tree/production" -%% click D href "https://github.com/stdlib-js/utils-curry-right/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-curry-right/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-curry-right/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/curry-right -[production-url]: https://github.com/stdlib-js/utils-curry-right/tree/production -[deno-url]: https://github.com/stdlib-js/utils-curry-right/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-curry-right/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-curry-right/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7271aed..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,53 +0,0 @@ - -{{alias}}( fcn[, arity][, thisArg] ) - Transforms a function into a sequence of functions each accepting a single - argument. - - Until return value resolution, each invocation returns a new partially - applied curry function. - - This function applies arguments starting from the right. - - Parameters - ---------- - fcn: Function - Function to curry. - - arity: integer (optional) - Number of parameters. Default: `fcn.length`. - - thisArg: any (optional) - Evaluation context. - - Returns - ------- - out: Function - Curry function. - - Examples - -------- - > function add( x, y ) { return x + y; }; - > var f = {{alias}}( add ); - > var sum = f( 2 )( 3 ) - 5 - - // Supply arity: - > function add() { return arguments[ 0 ] + arguments[ 1 ]; }; - > f = {{alias}}( add, 2 ); - > sum = f( 2 )( 3 ) - 5 - - // Provide function context: - > var obj = { - ... 'name': 'Ada', - ... 'greet': function greet( word1, word2 ) { - ... return word1 + ' ' + word2 + ', ' + this.name + '!' - ... } - ... }; - > f = {{alias}}( obj.greet, obj ); - > var str = f( 'there' )( 'Hello' ) - 'Hello there, Ada!' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a3b29c4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import curryRight = require( './index' ); - - -// TESTS // - -// The function returns a function... -{ - curryRight( ( x: number, y: number ): number => x + y ); // $ExpectType Closure - curryRight( ( x: number, y: number ): number => x + y, 2 ); // $ExpectType Closure - curryRight( ( x: number, y: number ): number => x + y, 2, {} ); // $ExpectType Closure -} - -// The compiler throws an error if the function is provided a first argument other than a function... -{ - curryRight( true ); // $ExpectError - curryRight( false ); // $ExpectError - curryRight( 5 ); // $ExpectError - curryRight( [] ); // $ExpectError - curryRight( {} ); // $ExpectError - curryRight( 'abc' ); // $ExpectError -} - -// The compiler throws an error if the function is provided more than three arguments... -{ - curryRight( ( x: number, y: number ): number => x + y, 2, {}, 4 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 76818ec..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 curryRight = require( './../lib' ); - -var fcn; -var out; -var i; - -function add( x, y, z, w, t, s ) { - return x + y + z + w + t + s; -} - -fcn = curryRight( add ); -out = fcn; -for ( i = 0; i < add.length; i++ ) { - out = out( i*10 ); -} -console.log( out ); 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..a30aaa4 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,i,s){var o,a;if(!e(n))throw new TypeError(r("0j23p",n));if(arguments.length<2){if(a=n.length,!t(a))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",a))}else if(arguments.length>2){if(o=s,!t(a=i))throw new TypeError(r("0j2Bi",a))}else if(t(i))a=i;else{if(a=n.length,!t(a))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",a));o=i}return l([]);function l(e){return function(t){var r=e.slice();if(r.unshift(t),r.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '0j2Bi', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","v","cargs","slice","unshift","apply"],"mappings":";;oSAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,SAE3H,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAEjC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,IAEjID,EAAUF,CACV,CACD,OAAOU,EAAe,IAStB,SAASA,EAAeC,GACvB,OASA,SAAkBC,GACjB,IAAIC,EAAQF,EAAKG,QAEjB,GADAD,EAAME,QAASH,GACVC,EAAML,OAASL,EACnB,OAAOO,EAAeG,GAEvB,OAAOd,EAAIiB,MAAOd,EAASW,EAC3B,CACD,CACF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 7e7d2e8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform a function into a sequence of functions each accepting a single argument. -* -* @module @stdlib/utils-curry-right -* -* @example -* var curryRight = require( '@stdlib/utils-curry-right' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ - -// 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 6eebd6a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* @param {Function} fcn - function to curry -* @param {PositiveInteger} [arity=fcn.length] - number of parameters -* @param {*} [thisArg] - evaluation context -* @throws {TypeError} first argument must be a function -* @throws {TypeError} first argument must be a function having at least one parameter -* @throws {TypeError} `arity` argument must be a positive integer -* @returns {Function} curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -function curryRight( fcn, arity, thisArg ) { - var context; - var len; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '0j23p', fcn ) ); - } - if ( arguments.length < 2 ) { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); - } - } else if ( arguments.length > 2 ) { - len = arity; - context = thisArg; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '0j2Bi', len ) ); - } - } else if ( isPositiveInteger( arity ) ) { - len = arity; - } else { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); - } - context = arity; - } - return createCurried( [] ); - - /** - * Returns a curry function. - * - * @private - * @param {Array} args - arguments - * @returns {Function} curry function - */ - function createCurried( args ) { - return curried; - - /** - * Curry function. - * - * @private - * @param {*} v - curried function parameter - * @returns {(Function|*)} partially applied curry function or curried function result - */ - function curried( v ) { - var cargs = args.slice(); - cargs.unshift( v ); - if ( cargs.length < len ) { - return createCurried( cargs ); - } - return fcn.apply( context, cargs ); - } - } -} - - -// EXPORTS // - -module.exports = curryRight; diff --git a/package.json b/package.json index 754a6c6..b53b05c 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.8", "description": "Transform a function into a sequence of functions each accepting a single argument.", "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,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.0.8", - "@stdlib/assert-is-positive-integer": "^0.0.7", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/bench": "^0.0.12", - "@stdlib/math-base-special-pow": "^0.0.7", - "@stdlib/random-base-randu": "^0.0.8", - "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..ed82908 --- /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 b455d23..0000000 --- a/test/test.js +++ /dev/null @@ -1,291 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var curryRight = require( './../lib' ); - - -// FUNCTIONS // - -function add( x, y, z ) { - return x + y + z; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof curryRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (1 arg)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (2 args; context)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an arity argument which is not a positive integer (3 args)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - 0, - -1, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( add, value, {} ); - }; - } -}); - -tape( 'the function returns a function', function test( t ) { - var fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function curries a function', function test( t) { - var fcn; - var f; - - fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'for each invocation where the invocation number is less than the arity, the curried function returns a new partially applied curry function', function test( t ) { - var sum; - var f0; - var f1; - var f2; - - // Initial curried function has no partially applied arguments... - f0 = curryRight( add ); - - sum = f0( 1 )( 2 )( 3 ); - t.strictEqual( sum, 6, 'returns 6' ); - - sum = f0( 1 )( 3 )( 5 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f0( 10 )( 20 )( 40 ); - t.strictEqual( sum, 70, 'returns 70' ); - - // If arity greater than 1, first invocation returns a curried function with one partially applied argument... - f1 = f0( 2 ); - - sum = f1( 3 )( 4 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f1( 10 )( 20 ); - t.strictEqual( sum, 32, 'returns 32' ); - - sum = f1( -1 )( -2 ); - t.strictEqual( sum, -1, 'returns -1' ); - - // If arity greater than 2, second invocation returns a curried function with two partially applied arguments... - f2 = f1( 3 ); - - sum = f2( 5 ); - t.strictEqual( sum, 10, 'returns 10' ); - - sum = f2( 6 ); - t.strictEqual( sum, 11, 'returns 11' ); - - sum = f2( 10 ); - t.strictEqual( sum, 15, 'returns 15' ); - - // And so on and so forth... - - t.end(); -}); - -tape( 'the function supports specifying a function arity', function test( t ) { - var fcn; - var f; - - function add() { - return arguments[ 0 ] + arguments[ 1 ] + arguments[ 2 ]; - } - - fcn = curryRight( add, 3 ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'the function supports specifying a function context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate( length, units, type, color ) { - return this.style+': '+length+units+' '+type+' '+color; - } - }; - - fcn = curryRight( context.generate, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); - -tape( 'the function supports specifying a function arity and context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate() { - return this.style+': '+arguments[0]+arguments[1]+' '+arguments[2]+' '+arguments[3]; - } - }; - - fcn = curryRight( context.generate, 4, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); From 0bcea11f207acf372013e1747ab4f6e934a290f9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 23 Sep 2023 14:46:06 +0000 Subject: [PATCH 056/140] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index 8d7768e..4552bfd 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -52,25 +52,25 @@ function curryRight( fcn, arity, thisArg ) { var context; var len; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '1SN3c,J9', fcn ) ); } if ( arguments.length < 2 ) { len = fcn.length; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); + throw new TypeError( format( '1SNPG', len ) ); } } else if ( arguments.length > 2 ) { len = arity; context = thisArg; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) ); + throw new TypeError( format( '1SNAz,On', len ) ); } } else if ( isPositiveInteger( arity ) ) { len = arity; } else { len = fcn.length; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); + throw new TypeError( format( '1SNPG', len ) ); } context = arity; } diff --git a/package.json b/package.json index 66357f1..f6e34ed 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-function": "^0.1.0", "@stdlib/assert-is-positive-integer": "^0.1.0", - "@stdlib/string-format": "^0.1.0" + "@stdlib/error-tools-fmtprodmsg": "^0.1.0" }, "devDependencies": { "@stdlib/bench": "^0.1.0", From 89924634db65f63bce001a70a52a2ce4f7af1395 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 23 Sep 2023 16:03:35 +0000 Subject: [PATCH 057/140] Remove files --- index.d.ts | 82 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6264 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 689a825..0000000 --- a/index.d.ts +++ /dev/null @@ -1,82 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/** -* Curry function. -* -* @param v - curried function parameter -* @returns partially applied curry function or curried function result -*/ -type Closure = ( v: any ) => any; - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param arity - number of parameters -* @param thisArg - evaluation context -* @throws `arity` must be a positive integer -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight( fcn: Function, arity: number, thisArg?: any ): Closure; // tslint-disable-line max-line-length - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param thisArg - evaluation context -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight( fcn: Function, thisArg?: any ): Closure; - - -// EXPORTS // - -export = curryRight; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index a30aaa4..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";function n(n,i,s){var o,a;if(!e(n))throw new TypeError(r("0j23p",n));if(arguments.length<2){if(a=n.length,!t(a))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",a))}else if(arguments.length>2){if(o=s,!t(a=i))throw new TypeError(r("0j2Bi",a))}else if(t(i))a=i;else{if(a=n.length,!t(a))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",a));o=i}return l([]);function l(e){return function(t){var r=e.slice();if(r.unshift(t),r.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '0j2Bi', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","v","cargs","slice","unshift","apply"],"mappings":";;oSAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,SAE3H,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAEjC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,IAEjID,EAAUF,CACV,CACD,OAAOU,EAAe,IAStB,SAASA,EAAeC,GACvB,OASA,SAAkBC,GACjB,IAAIC,EAAQF,EAAKG,QAEjB,GADAD,EAAME,QAASH,GACVC,EAAML,OAASL,EACnB,OAAOO,EAAeG,GAEvB,OAAOd,EAAIiB,MAAOd,EAASW,EAC3B,CACD,CACF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index ed82908..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 2c1fa93a4c54d11f2cb698cbe5c87b46eb8ec2f1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 23 Sep 2023 16:05:14 +0000 Subject: [PATCH 058/140] 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 | 39 +- benchmark/benchmark.js | 90 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 53 - docs/types/test.ts | 44 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 110 - package.json | 55 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 291 - 40 files changed, 6200 insertions(+), 3915 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 2b7fad0..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/curry-right) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 26300c3..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/curry-right) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 b01c884..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: '6 18 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 91f2b93..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,783 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -258,7 +251,7 @@ console.log( out ); ## 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]. @@ -320,11 +313,11 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry +[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry/tree/esm -[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry +[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry/tree/esm -[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right +[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index fbb976c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isFunction = require( '@stdlib/assert-is-function' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var curryRight = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = curryRight( pow ); - if ( typeof out !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( out ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::returned_function', function benchmark( b ) { - var fcn; - var out; - var i; - - fcn = curryRight( pow ); - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = fcn( randu() )( randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::direct', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = pow( randu(), randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1f7cde2..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/curry-right" -%% click B href "https://github.com/stdlib-js/utils-curry-right/tree/main" -%% click C href "https://github.com/stdlib-js/utils-curry-right/tree/production" -%% click D href "https://github.com/stdlib-js/utils-curry-right/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-curry-right/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-curry-right/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/curry-right -[production-url]: https://github.com/stdlib-js/utils-curry-right/tree/production -[deno-url]: https://github.com/stdlib-js/utils-curry-right/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-curry-right/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-curry-right/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 8166962..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import curryRight from '../docs/types/index'; -export = curryRight; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 16477e0..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var g=f(function(b,o){ -var c=require('@stdlib/assert-is-function/dist'),n=require('@stdlib/assert-is-positive-integer/dist').isPrimitive,a=require('@stdlib/error-tools-fmtprodmsg/dist');function p(t,r,l){var u,e;if(!c(t))throw new TypeError(a('1SN3c',t));if(arguments.length<2){if(e=t.length,!n(e))throw new TypeError(a('1SNEX',e))}else if(arguments.length>2){if(e=r,u=l,!n(e))throw new TypeError(a('1SNAz',e))}else if(n(r))e=r;else{if(e=t.length,!n(e))throw new TypeError(a('1SNEX',e));u=r}return s([]);function s(m){return v;function v(h){var i=m.slice();return i.unshift(h),i.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = curryRight;\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* Transform a function into a sequence of functions each accepting a single argument.\n*\n* @module @stdlib/utils-curry-right\n*\n* @example\n* var curryRight = require( '@stdlib/utils-curry-right' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var f = curryRight( add );\n*\n* var sum = f( 2 )( 3 );\n* // returns 5\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,EAAoB,QAAS,oCAAqC,EAAE,YACpEC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,EAAYC,EAAKC,EAAOC,EAAU,CAC1C,IAAIC,EACAC,EACJ,GAAK,CAACR,EAAYI,CAAI,EACrB,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAI,CAAE,EAEzG,GAAK,UAAU,OAAS,GAEvB,GADAI,EAAMJ,EAAI,OACL,CAACH,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,kGAAmGM,CAAI,CAAE,UAE5H,UAAU,OAAS,GAG9B,GAFAA,EAAMH,EACNE,EAAUD,EACL,CAACL,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,4EAA6EM,CAAI,CAAE,UAEtGP,EAAmBI,CAAM,EACpCG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAI,OACL,CAACH,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,kGAAmGM,CAAI,CAAE,EAEvID,EAAUF,CACX,CACA,OAAOI,EAAe,CAAC,CAAE,EASzB,SAASA,EAAeC,EAAO,CAC9B,OAAOC,EASP,SAASA,EAASC,EAAI,CACrB,IAAIC,EAAQH,EAAK,MAAM,EAEvB,OADAG,EAAM,QAASD,CAAE,EACZC,EAAM,OAASL,EACZC,EAAeI,CAAM,EAEtBT,EAAI,MAAOG,EAASM,CAAM,CAClC,CACD,CACD,CAKAd,EAAO,QAAUI,ICrEjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isPositiveInteger", "format", "curryRight", "fcn", "arity", "thisArg", "context", "len", "createCurried", "args", "curried", "v", "cargs", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7271aed..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,53 +0,0 @@ - -{{alias}}( fcn[, arity][, thisArg] ) - Transforms a function into a sequence of functions each accepting a single - argument. - - Until return value resolution, each invocation returns a new partially - applied curry function. - - This function applies arguments starting from the right. - - Parameters - ---------- - fcn: Function - Function to curry. - - arity: integer (optional) - Number of parameters. Default: `fcn.length`. - - thisArg: any (optional) - Evaluation context. - - Returns - ------- - out: Function - Curry function. - - Examples - -------- - > function add( x, y ) { return x + y; }; - > var f = {{alias}}( add ); - > var sum = f( 2 )( 3 ) - 5 - - // Supply arity: - > function add() { return arguments[ 0 ] + arguments[ 1 ]; }; - > f = {{alias}}( add, 2 ); - > sum = f( 2 )( 3 ) - 5 - - // Provide function context: - > var obj = { - ... 'name': 'Ada', - ... 'greet': function greet( word1, word2 ) { - ... return word1 + ' ' + word2 + ', ' + this.name + '!' - ... } - ... }; - > f = {{alias}}( obj.greet, obj ); - > var str = f( 'there' )( 'Hello' ) - 'Hello there, Ada!' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a3b29c4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import curryRight = require( './index' ); - - -// TESTS // - -// The function returns a function... -{ - curryRight( ( x: number, y: number ): number => x + y ); // $ExpectType Closure - curryRight( ( x: number, y: number ): number => x + y, 2 ); // $ExpectType Closure - curryRight( ( x: number, y: number ): number => x + y, 2, {} ); // $ExpectType Closure -} - -// The compiler throws an error if the function is provided a first argument other than a function... -{ - curryRight( true ); // $ExpectError - curryRight( false ); // $ExpectError - curryRight( 5 ); // $ExpectError - curryRight( [] ); // $ExpectError - curryRight( {} ); // $ExpectError - curryRight( 'abc' ); // $ExpectError -} - -// The compiler throws an error if the function is provided more than three arguments... -{ - curryRight( ( x: number, y: number ): number => x + y, 2, {}, 4 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 76818ec..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 curryRight = require( './../lib' ); - -var fcn; -var out; -var i; - -function add( x, y, z, w, t, s ) { - return x + y + z + w + t + s; -} - -fcn = curryRight( add ); -out = fcn; -for ( i = 0; i < add.length; i++ ) { - out = out( i*10 ); -} -console.log( out ); 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..e26840e --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.0-esm/index.mjs";import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@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,s,i){var o,f;if(!e(n))throw new TypeError(t("1SN3c,J9",n));if(arguments.length<2){if(f=n.length,!r(f))throw new TypeError(t("1SNPG",f))}else if(arguments.length>2){if(o=i,!r(f=s))throw new TypeError(t("1SNAz,On",f))}else if(r(s))f=s;else{if(f=n.length,!r(f))throw new TypeError(t("1SNPG",f));o=s}return l([]);function l(e){return function(r){var t=e.slice();if(t.unshift(r),t.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNAz,On', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNPG', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","v","cargs","slice","unshift","apply"],"mappings":";;2SAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,WAAYP,IAE1C,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,SAEjC,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,WAAYH,SAEpC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvCD,EAAUF,CACV,CACD,OAAOU,EAAe,IAStB,SAASA,EAAeC,GACvB,OASA,SAAkBC,GACjB,IAAIC,EAAQF,EAAKG,QAEjB,GADAD,EAAME,QAASH,GACVC,EAAML,OAASL,EACnB,OAAOO,EAAeG,GAEvB,OAAOd,EAAIiB,MAAOd,EAASW,EAC3B,CACD,CACF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 7e7d2e8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform a function into a sequence of functions each accepting a single argument. -* -* @module @stdlib/utils-curry-right -* -* @example -* var curryRight = require( '@stdlib/utils-curry-right' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ - -// 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 4552bfd..0000000 --- a/lib/main.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* @param {Function} fcn - function to curry -* @param {PositiveInteger} [arity=fcn.length] - number of parameters -* @param {*} [thisArg] - evaluation context -* @throws {TypeError} first argument must be a function -* @throws {TypeError} first argument must be a function having at least one parameter -* @throws {TypeError} `arity` argument must be a positive integer -* @returns {Function} curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -function curryRight( fcn, arity, thisArg ) { - var context; - var len; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '1SN3c,J9', fcn ) ); - } - if ( arguments.length < 2 ) { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNPG', len ) ); - } - } else if ( arguments.length > 2 ) { - len = arity; - context = thisArg; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNAz,On', len ) ); - } - } else if ( isPositiveInteger( arity ) ) { - len = arity; - } else { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNPG', len ) ); - } - context = arity; - } - return createCurried( [] ); - - /** - * Returns a curry function. - * - * @private - * @param {Array} args - arguments - * @returns {Function} curry function - */ - function createCurried( args ) { - return curried; - - /** - * Curry function. - * - * @private - * @param {*} v - curried function parameter - * @returns {(Function|*)} partially applied curry function or curried function result - */ - function curried( v ) { - var cargs = args.slice(); - cargs.unshift( v ); - if ( cargs.length < len ) { - return createCurried( cargs ); - } - return fcn.apply( context, cargs ); - } - } -} - - -// EXPORTS // - -module.exports = curryRight; diff --git a/package.json b/package.json index f6e34ed..206209e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Transform a function into a sequence of functions each accepting a single argument.", "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,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.1.0", - "@stdlib/assert-is-positive-integer": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.0" - }, - "devDependencies": { - "@stdlib/bench": "^0.1.0", - "@stdlib/math-base-special-pow": "^0.0.7", - "@stdlib/random-base-randu": "^0.0.8", - "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..b09c105 --- /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 b455d23..0000000 --- a/test/test.js +++ /dev/null @@ -1,291 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var curryRight = require( './../lib' ); - - -// FUNCTIONS // - -function add( x, y, z ) { - return x + y + z; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof curryRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (1 arg)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (2 args; context)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an arity argument which is not a positive integer (3 args)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - 0, - -1, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( add, value, {} ); - }; - } -}); - -tape( 'the function returns a function', function test( t ) { - var fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function curries a function', function test( t) { - var fcn; - var f; - - fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'for each invocation where the invocation number is less than the arity, the curried function returns a new partially applied curry function', function test( t ) { - var sum; - var f0; - var f1; - var f2; - - // Initial curried function has no partially applied arguments... - f0 = curryRight( add ); - - sum = f0( 1 )( 2 )( 3 ); - t.strictEqual( sum, 6, 'returns 6' ); - - sum = f0( 1 )( 3 )( 5 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f0( 10 )( 20 )( 40 ); - t.strictEqual( sum, 70, 'returns 70' ); - - // If arity greater than 1, first invocation returns a curried function with one partially applied argument... - f1 = f0( 2 ); - - sum = f1( 3 )( 4 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f1( 10 )( 20 ); - t.strictEqual( sum, 32, 'returns 32' ); - - sum = f1( -1 )( -2 ); - t.strictEqual( sum, -1, 'returns -1' ); - - // If arity greater than 2, second invocation returns a curried function with two partially applied arguments... - f2 = f1( 3 ); - - sum = f2( 5 ); - t.strictEqual( sum, 10, 'returns 10' ); - - sum = f2( 6 ); - t.strictEqual( sum, 11, 'returns 11' ); - - sum = f2( 10 ); - t.strictEqual( sum, 15, 'returns 15' ); - - // And so on and so forth... - - t.end(); -}); - -tape( 'the function supports specifying a function arity', function test( t ) { - var fcn; - var f; - - function add() { - return arguments[ 0 ] + arguments[ 1 ] + arguments[ 2 ]; - } - - fcn = curryRight( add, 3 ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'the function supports specifying a function context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate( length, units, type, color ) { - return this.style+': '+length+units+' '+type+' '+color; - } - }; - - fcn = curryRight( context.generate, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); - -tape( 'the function supports specifying a function arity and context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate() { - return this.style+': '+arguments[0]+arguments[1]+' '+arguments[2]+' '+arguments[3]; - } - }; - - fcn = curryRight( context.generate, 4, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); From b5658dd95c0b7a0bc45290a8e50375b92223c54d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 23 Sep 2023 16:51:06 +0000 Subject: [PATCH 059/140] 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 a87d208..b45fd63 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import curryRight from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-curry-right@esm/index.mjs'; +import curryRight from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-curry-right@v0.1.0-esm/index.mjs'; ``` #### curryRight( fcn\[, arity]\[, thisArg] ) @@ -192,7 +192,7 @@ var str = fcn( 'there' )( 'Hello' ); - - - - From 1475d1b5acbc9dd5168aabc239f33f2faa2c599a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 2 Oct 2023 11:03:17 +0000 Subject: [PATCH 063/140] 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 | 39 +- benchmark/benchmark.js | 90 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 53 - docs/types/test.ts | 44 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 110 - package.json | 55 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 291 - test/test.js | 291 - 42 files changed, 6200 insertions(+), 4265 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 b7d379f..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-10-01T02:33:56.271Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2b7fad0..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/curry-right) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 9ffcfa1..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/curry-right) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 eb2ed9f..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: '6 18 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -258,7 +251,7 @@ console.log( out ); ## 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]. @@ -320,11 +313,11 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry +[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry/tree/esm -[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry +[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry/tree/esm -[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right +[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index fbb976c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isFunction = require( '@stdlib/assert-is-function' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var curryRight = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = curryRight( pow ); - if ( typeof out !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( out ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::returned_function', function benchmark( b ) { - var fcn; - var out; - var i; - - fcn = curryRight( pow ); - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = fcn( randu() )( randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::direct', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = pow( randu(), randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1f7cde2..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/curry-right" -%% click B href "https://github.com/stdlib-js/utils-curry-right/tree/main" -%% click C href "https://github.com/stdlib-js/utils-curry-right/tree/production" -%% click D href "https://github.com/stdlib-js/utils-curry-right/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-curry-right/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-curry-right/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/curry-right -[production-url]: https://github.com/stdlib-js/utils-curry-right/tree/production -[deno-url]: https://github.com/stdlib-js/utils-curry-right/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-curry-right/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-curry-right/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 8166962..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import curryRight from '../docs/types/index'; -export = curryRight; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 16477e0..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var g=f(function(b,o){ -var c=require('@stdlib/assert-is-function/dist'),n=require('@stdlib/assert-is-positive-integer/dist').isPrimitive,a=require('@stdlib/error-tools-fmtprodmsg/dist');function p(t,r,l){var u,e;if(!c(t))throw new TypeError(a('1SN3c',t));if(arguments.length<2){if(e=t.length,!n(e))throw new TypeError(a('1SNEX',e))}else if(arguments.length>2){if(e=r,u=l,!n(e))throw new TypeError(a('1SNAz',e))}else if(n(r))e=r;else{if(e=t.length,!n(e))throw new TypeError(a('1SNEX',e));u=r}return s([]);function s(m){return v;function v(h){var i=m.slice();return i.unshift(h),i.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = curryRight;\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* Transform a function into a sequence of functions each accepting a single argument.\n*\n* @module @stdlib/utils-curry-right\n*\n* @example\n* var curryRight = require( '@stdlib/utils-curry-right' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var f = curryRight( add );\n*\n* var sum = f( 2 )( 3 );\n* // returns 5\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,EAAoB,QAAS,oCAAqC,EAAE,YACpEC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,EAAYC,EAAKC,EAAOC,EAAU,CAC1C,IAAIC,EACAC,EACJ,GAAK,CAACR,EAAYI,CAAI,EACrB,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAI,CAAE,EAEzG,GAAK,UAAU,OAAS,GAEvB,GADAI,EAAMJ,EAAI,OACL,CAACH,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,kGAAmGM,CAAI,CAAE,UAE5H,UAAU,OAAS,GAG9B,GAFAA,EAAMH,EACNE,EAAUD,EACL,CAACL,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,4EAA6EM,CAAI,CAAE,UAEtGP,EAAmBI,CAAM,EACpCG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAI,OACL,CAACH,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,kGAAmGM,CAAI,CAAE,EAEvID,EAAUF,CACX,CACA,OAAOI,EAAe,CAAC,CAAE,EASzB,SAASA,EAAeC,EAAO,CAC9B,OAAOC,EASP,SAASA,EAASC,EAAI,CACrB,IAAIC,EAAQH,EAAK,MAAM,EAEvB,OADAG,EAAM,QAASD,CAAE,EACZC,EAAM,OAASL,EACZC,EAAeI,CAAM,EAEtBT,EAAI,MAAOG,EAASM,CAAM,CAClC,CACD,CACD,CAKAd,EAAO,QAAUI,ICrEjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isPositiveInteger", "format", "curryRight", "fcn", "arity", "thisArg", "context", "len", "createCurried", "args", "curried", "v", "cargs", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7271aed..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,53 +0,0 @@ - -{{alias}}( fcn[, arity][, thisArg] ) - Transforms a function into a sequence of functions each accepting a single - argument. - - Until return value resolution, each invocation returns a new partially - applied curry function. - - This function applies arguments starting from the right. - - Parameters - ---------- - fcn: Function - Function to curry. - - arity: integer (optional) - Number of parameters. Default: `fcn.length`. - - thisArg: any (optional) - Evaluation context. - - Returns - ------- - out: Function - Curry function. - - Examples - -------- - > function add( x, y ) { return x + y; }; - > var f = {{alias}}( add ); - > var sum = f( 2 )( 3 ) - 5 - - // Supply arity: - > function add() { return arguments[ 0 ] + arguments[ 1 ]; }; - > f = {{alias}}( add, 2 ); - > sum = f( 2 )( 3 ) - 5 - - // Provide function context: - > var obj = { - ... 'name': 'Ada', - ... 'greet': function greet( word1, word2 ) { - ... return word1 + ' ' + word2 + ', ' + this.name + '!' - ... } - ... }; - > f = {{alias}}( obj.greet, obj ); - > var str = f( 'there' )( 'Hello' ) - 'Hello there, Ada!' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a3b29c4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import curryRight = require( './index' ); - - -// TESTS // - -// The function returns a function... -{ - curryRight( ( x: number, y: number ): number => x + y ); // $ExpectType Closure - curryRight( ( x: number, y: number ): number => x + y, 2 ); // $ExpectType Closure - curryRight( ( x: number, y: number ): number => x + y, 2, {} ); // $ExpectType Closure -} - -// The compiler throws an error if the function is provided a first argument other than a function... -{ - curryRight( true ); // $ExpectError - curryRight( false ); // $ExpectError - curryRight( 5 ); // $ExpectError - curryRight( [] ); // $ExpectError - curryRight( {} ); // $ExpectError - curryRight( 'abc' ); // $ExpectError -} - -// The compiler throws an error if the function is provided more than three arguments... -{ - curryRight( ( x: number, y: number ): number => x + y, 2, {}, 4 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 76818ec..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 curryRight = require( './../lib' ); - -var fcn; -var out; -var i; - -function add( x, y, z, w, t, s ) { - return x + y + z + w + t + s; -} - -fcn = curryRight( add ); -out = fcn; -for ( i = 0; i < add.length; i++ ) { - out = out( i*10 ); -} -console.log( out ); 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..8e7c0bf --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.0-esm/index.mjs";import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@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,s,i){var o,f;if(!e(n))throw new TypeError(t("1SN3c,J9",n));if(arguments.length<2){if(f=n.length,!r(f))throw new TypeError(t("1SNPG",f))}else if(arguments.length>2){if(o=i,!r(f=s))throw new TypeError(t("1SNAz,On",f))}else if(r(s))f=s;else{if(f=n.length,!r(f))throw new TypeError(t("1SNPG",f));o=s}return l([]);function l(e){return function(r){var t=e.slice();if(t.unshift(r),t.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNAz,On', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNPG', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","v","cargs","slice","unshift","apply"],"mappings":";;kTAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,WAAYP,IAE1C,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,SAEjC,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,WAAYH,SAEpC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvCD,EAAUF,CACV,CACD,OAAOU,EAAe,IAStB,SAASA,EAAeC,GACvB,OASA,SAAkBC,GACjB,IAAIC,EAAQF,EAAKG,QAEjB,GADAD,EAAME,QAASH,GACVC,EAAML,OAASL,EACnB,OAAOO,EAAeG,GAEvB,OAAOd,EAAIiB,MAAOd,EAASW,EAC3B,CACD,CACF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 7e7d2e8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform a function into a sequence of functions each accepting a single argument. -* -* @module @stdlib/utils-curry-right -* -* @example -* var curryRight = require( '@stdlib/utils-curry-right' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ - -// 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 4552bfd..0000000 --- a/lib/main.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* @param {Function} fcn - function to curry -* @param {PositiveInteger} [arity=fcn.length] - number of parameters -* @param {*} [thisArg] - evaluation context -* @throws {TypeError} first argument must be a function -* @throws {TypeError} first argument must be a function having at least one parameter -* @throws {TypeError} `arity` argument must be a positive integer -* @returns {Function} curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -function curryRight( fcn, arity, thisArg ) { - var context; - var len; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '1SN3c,J9', fcn ) ); - } - if ( arguments.length < 2 ) { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNPG', len ) ); - } - } else if ( arguments.length > 2 ) { - len = arity; - context = thisArg; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNAz,On', len ) ); - } - } else if ( isPositiveInteger( arity ) ) { - len = arity; - } else { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNPG', len ) ); - } - context = arity; - } - return createCurried( [] ); - - /** - * Returns a curry function. - * - * @private - * @param {Array} args - arguments - * @returns {Function} curry function - */ - function createCurried( args ) { - return curried; - - /** - * Curry function. - * - * @private - * @param {*} v - curried function parameter - * @returns {(Function|*)} partially applied curry function or curried function result - */ - function curried( v ) { - var cargs = args.slice(); - cargs.unshift( v ); - if ( cargs.length < len ) { - return createCurried( cargs ); - } - return fcn.apply( context, cargs ); - } - } -} - - -// EXPORTS // - -module.exports = curryRight; diff --git a/package.json b/package.json index a74812b..206209e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Transform a function into a sequence of functions each accepting a single argument.", "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,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.1.0", - "@stdlib/assert-is-positive-integer": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.0" - }, - "devDependencies": { - "@stdlib/bench": "^0.1.0", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/random-base-randu": "^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..29cc115 --- /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 36b2432..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,291 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var curryRight = require( './../../dist' ); - - -// FUNCTIONS // - -function add( x, y, z ) { - return x + y + z; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof curryRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (1 arg)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (2 args; context)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an arity argument which is not a positive integer (3 args)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - 0, - -1, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( add, value, {} ); - }; - } -}); - -tape( 'the function returns a function', function test( t ) { - var fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function curries a function', function test( t) { - var fcn; - var f; - - fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'for each invocation where the invocation number is less than the arity, the curried function returns a new partially applied curry function', function test( t ) { - var sum; - var f0; - var f1; - var f2; - - // Initial curried function has no partially applied arguments... - f0 = curryRight( add ); - - sum = f0( 1 )( 2 )( 3 ); - t.strictEqual( sum, 6, 'returns 6' ); - - sum = f0( 1 )( 3 )( 5 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f0( 10 )( 20 )( 40 ); - t.strictEqual( sum, 70, 'returns 70' ); - - // If arity greater than 1, first invocation returns a curried function with one partially applied argument... - f1 = f0( 2 ); - - sum = f1( 3 )( 4 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f1( 10 )( 20 ); - t.strictEqual( sum, 32, 'returns 32' ); - - sum = f1( -1 )( -2 ); - t.strictEqual( sum, -1, 'returns -1' ); - - // If arity greater than 2, second invocation returns a curried function with two partially applied arguments... - f2 = f1( 3 ); - - sum = f2( 5 ); - t.strictEqual( sum, 10, 'returns 10' ); - - sum = f2( 6 ); - t.strictEqual( sum, 11, 'returns 11' ); - - sum = f2( 10 ); - t.strictEqual( sum, 15, 'returns 15' ); - - // And so on and so forth... - - t.end(); -}); - -tape( 'the function supports specifying a function arity', function test( t ) { - var fcn; - var f; - - function add() { - return arguments[ 0 ] + arguments[ 1 ] + arguments[ 2 ]; - } - - fcn = curryRight( add, 3 ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'the function supports specifying a function context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate( length, units, type, color ) { - return this.style+': '+length+units+' '+type+' '+color; - } - }; - - fcn = curryRight( context.generate, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); - -tape( 'the function supports specifying a function arity and context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate() { - return this.style+': '+arguments[0]+arguments[1]+' '+arguments[2]+' '+arguments[3]; - } - }; - - fcn = curryRight( context.generate, 4, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index b455d23..0000000 --- a/test/test.js +++ /dev/null @@ -1,291 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var curryRight = require( './../lib' ); - - -// FUNCTIONS // - -function add( x, y, z ) { - return x + y + z; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof curryRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (1 arg)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (2 args; context)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an arity argument which is not a positive integer (3 args)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - 0, - -1, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( add, value, {} ); - }; - } -}); - -tape( 'the function returns a function', function test( t ) { - var fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function curries a function', function test( t) { - var fcn; - var f; - - fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'for each invocation where the invocation number is less than the arity, the curried function returns a new partially applied curry function', function test( t ) { - var sum; - var f0; - var f1; - var f2; - - // Initial curried function has no partially applied arguments... - f0 = curryRight( add ); - - sum = f0( 1 )( 2 )( 3 ); - t.strictEqual( sum, 6, 'returns 6' ); - - sum = f0( 1 )( 3 )( 5 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f0( 10 )( 20 )( 40 ); - t.strictEqual( sum, 70, 'returns 70' ); - - // If arity greater than 1, first invocation returns a curried function with one partially applied argument... - f1 = f0( 2 ); - - sum = f1( 3 )( 4 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f1( 10 )( 20 ); - t.strictEqual( sum, 32, 'returns 32' ); - - sum = f1( -1 )( -2 ); - t.strictEqual( sum, -1, 'returns -1' ); - - // If arity greater than 2, second invocation returns a curried function with two partially applied arguments... - f2 = f1( 3 ); - - sum = f2( 5 ); - t.strictEqual( sum, 10, 'returns 10' ); - - sum = f2( 6 ); - t.strictEqual( sum, 11, 'returns 11' ); - - sum = f2( 10 ); - t.strictEqual( sum, 15, 'returns 15' ); - - // And so on and so forth... - - t.end(); -}); - -tape( 'the function supports specifying a function arity', function test( t ) { - var fcn; - var f; - - function add() { - return arguments[ 0 ] + arguments[ 1 ] + arguments[ 2 ]; - } - - fcn = curryRight( add, 3 ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'the function supports specifying a function context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate( length, units, type, color ) { - return this.style+': '+length+units+' '+type+' '+color; - } - }; - - fcn = curryRight( context.generate, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); - -tape( 'the function supports specifying a function arity and context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate() { - return this.style+': '+arguments[0]+arguments[1]+' '+arguments[2]+' '+arguments[3]; - } - }; - - fcn = curryRight( context.generate, 4, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); From 7faaf4f10a39b05785710cf6c95a308076461fad Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 5 Oct 2023 10:00:33 +0000 Subject: [PATCH 064/140] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index 8d7768e..4552bfd 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -52,25 +52,25 @@ function curryRight( fcn, arity, thisArg ) { var context; var len; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '1SN3c,J9', fcn ) ); } if ( arguments.length < 2 ) { len = fcn.length; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); + throw new TypeError( format( '1SNPG', len ) ); } } else if ( arguments.length > 2 ) { len = arity; context = thisArg; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) ); + throw new TypeError( format( '1SNAz,On', len ) ); } } else if ( isPositiveInteger( arity ) ) { len = arity; } else { len = fcn.length; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); + throw new TypeError( format( '1SNPG', len ) ); } context = arity; } diff --git a/package.json b/package.json index 053bdd4..c200d1b 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-function": "^0.1.1", "@stdlib/assert-is-positive-integer": "^0.1.0", - "@stdlib/string-format": "^0.1.1" + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/bench": "^0.1.0", From fea03994dc2aeff455ab9a02fd7be1cfe87ff07d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 6 Oct 2023 13:01:45 +0000 Subject: [PATCH 065/140] Remove files --- index.d.ts | 82 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6264 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 ee0b7ce..0000000 --- a/index.d.ts +++ /dev/null @@ -1,82 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Curry function. -* -* @param v - curried function parameter -* @returns partially applied curry function or curried function result -*/ -type Closure = ( v: any ) => any; - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param arity - number of parameters -* @param thisArg - evaluation context -* @throws `arity` must be a positive integer -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight( fcn: Function, arity: number, thisArg?: any ): Closure; // tslint-disable-line max-line-length - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param thisArg - evaluation context -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight( fcn: Function, thisArg?: any ): Closure; - - -// EXPORTS // - -export = curryRight; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 8e7c0bf..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.0-esm/index.mjs";import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@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,s,i){var o,f;if(!e(n))throw new TypeError(t("1SN3c,J9",n));if(arguments.length<2){if(f=n.length,!r(f))throw new TypeError(t("1SNPG",f))}else if(arguments.length>2){if(o=i,!r(f=s))throw new TypeError(t("1SNAz,On",f))}else if(r(s))f=s;else{if(f=n.length,!r(f))throw new TypeError(t("1SNPG",f));o=s}return l([]);function l(e){return function(r){var t=e.slice();if(t.unshift(r),t.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNAz,On', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNPG', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","v","cargs","slice","unshift","apply"],"mappings":";;kTAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,WAAYP,IAE1C,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,SAEjC,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,WAAYH,SAEpC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvCD,EAAUF,CACV,CACD,OAAOU,EAAe,IAStB,SAASA,EAAeC,GACvB,OASA,SAAkBC,GACjB,IAAIC,EAAQF,EAAKG,QAEjB,GADAD,EAAME,QAASH,GACVC,EAAML,OAASL,EACnB,OAAOO,EAAeG,GAEvB,OAAOd,EAAIiB,MAAOd,EAASW,EAC3B,CACD,CACF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 29cc115..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 7977192132d7b9106881e8709c319cede6d7e194 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 6 Oct 2023 13:04:59 +0000 Subject: [PATCH 066/140] 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 | 39 +- benchmark/benchmark.js | 90 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 53 - docs/types/test.ts | 44 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 110 - package.json | 55 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 291 - test/test.js | 291 - 41 files changed, 6200 insertions(+), 4264 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 2b7fad0..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/curry-right) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 9ffcfa1..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/curry-right) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 eb2ed9f..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: '6 18 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -258,7 +251,7 @@ console.log( out ); ## 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]. @@ -320,11 +313,11 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry +[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry/tree/esm -[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry +[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry/tree/esm -[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right +[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index fbb976c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isFunction = require( '@stdlib/assert-is-function' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var curryRight = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = curryRight( pow ); - if ( typeof out !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( out ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::returned_function', function benchmark( b ) { - var fcn; - var out; - var i; - - fcn = curryRight( pow ); - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = fcn( randu() )( randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::direct', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = pow( randu(), randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1f7cde2..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/curry-right" -%% click B href "https://github.com/stdlib-js/utils-curry-right/tree/main" -%% click C href "https://github.com/stdlib-js/utils-curry-right/tree/production" -%% click D href "https://github.com/stdlib-js/utils-curry-right/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-curry-right/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-curry-right/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/curry-right -[production-url]: https://github.com/stdlib-js/utils-curry-right/tree/production -[deno-url]: https://github.com/stdlib-js/utils-curry-right/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-curry-right/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-curry-right/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 8166962..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import curryRight from '../docs/types/index'; -export = curryRight; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 16477e0..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var g=f(function(b,o){ -var c=require('@stdlib/assert-is-function/dist'),n=require('@stdlib/assert-is-positive-integer/dist').isPrimitive,a=require('@stdlib/error-tools-fmtprodmsg/dist');function p(t,r,l){var u,e;if(!c(t))throw new TypeError(a('1SN3c',t));if(arguments.length<2){if(e=t.length,!n(e))throw new TypeError(a('1SNEX',e))}else if(arguments.length>2){if(e=r,u=l,!n(e))throw new TypeError(a('1SNAz',e))}else if(n(r))e=r;else{if(e=t.length,!n(e))throw new TypeError(a('1SNEX',e));u=r}return s([]);function s(m){return v;function v(h){var i=m.slice();return i.unshift(h),i.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = curryRight;\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* Transform a function into a sequence of functions each accepting a single argument.\n*\n* @module @stdlib/utils-curry-right\n*\n* @example\n* var curryRight = require( '@stdlib/utils-curry-right' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var f = curryRight( add );\n*\n* var sum = f( 2 )( 3 );\n* // returns 5\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,EAAoB,QAAS,oCAAqC,EAAE,YACpEC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,EAAYC,EAAKC,EAAOC,EAAU,CAC1C,IAAIC,EACAC,EACJ,GAAK,CAACR,EAAYI,CAAI,EACrB,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAI,CAAE,EAEzG,GAAK,UAAU,OAAS,GAEvB,GADAI,EAAMJ,EAAI,OACL,CAACH,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,kGAAmGM,CAAI,CAAE,UAE5H,UAAU,OAAS,GAG9B,GAFAA,EAAMH,EACNE,EAAUD,EACL,CAACL,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,4EAA6EM,CAAI,CAAE,UAEtGP,EAAmBI,CAAM,EACpCG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAI,OACL,CAACH,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,kGAAmGM,CAAI,CAAE,EAEvID,EAAUF,CACX,CACA,OAAOI,EAAe,CAAC,CAAE,EASzB,SAASA,EAAeC,EAAO,CAC9B,OAAOC,EASP,SAASA,EAASC,EAAI,CACrB,IAAIC,EAAQH,EAAK,MAAM,EAEvB,OADAG,EAAM,QAASD,CAAE,EACZC,EAAM,OAASL,EACZC,EAAeI,CAAM,EAEtBT,EAAI,MAAOG,EAASM,CAAM,CAClC,CACD,CACD,CAKAd,EAAO,QAAUI,ICrEjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isPositiveInteger", "format", "curryRight", "fcn", "arity", "thisArg", "context", "len", "createCurried", "args", "curried", "v", "cargs", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7271aed..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,53 +0,0 @@ - -{{alias}}( fcn[, arity][, thisArg] ) - Transforms a function into a sequence of functions each accepting a single - argument. - - Until return value resolution, each invocation returns a new partially - applied curry function. - - This function applies arguments starting from the right. - - Parameters - ---------- - fcn: Function - Function to curry. - - arity: integer (optional) - Number of parameters. Default: `fcn.length`. - - thisArg: any (optional) - Evaluation context. - - Returns - ------- - out: Function - Curry function. - - Examples - -------- - > function add( x, y ) { return x + y; }; - > var f = {{alias}}( add ); - > var sum = f( 2 )( 3 ) - 5 - - // Supply arity: - > function add() { return arguments[ 0 ] + arguments[ 1 ]; }; - > f = {{alias}}( add, 2 ); - > sum = f( 2 )( 3 ) - 5 - - // Provide function context: - > var obj = { - ... 'name': 'Ada', - ... 'greet': function greet( word1, word2 ) { - ... return word1 + ' ' + word2 + ', ' + this.name + '!' - ... } - ... }; - > f = {{alias}}( obj.greet, obj ); - > var str = f( 'there' )( 'Hello' ) - 'Hello there, Ada!' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a3b29c4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import curryRight = require( './index' ); - - -// TESTS // - -// The function returns a function... -{ - curryRight( ( x: number, y: number ): number => x + y ); // $ExpectType Closure - curryRight( ( x: number, y: number ): number => x + y, 2 ); // $ExpectType Closure - curryRight( ( x: number, y: number ): number => x + y, 2, {} ); // $ExpectType Closure -} - -// The compiler throws an error if the function is provided a first argument other than a function... -{ - curryRight( true ); // $ExpectError - curryRight( false ); // $ExpectError - curryRight( 5 ); // $ExpectError - curryRight( [] ); // $ExpectError - curryRight( {} ); // $ExpectError - curryRight( 'abc' ); // $ExpectError -} - -// The compiler throws an error if the function is provided more than three arguments... -{ - curryRight( ( x: number, y: number ): number => x + y, 2, {}, 4 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 76818ec..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 curryRight = require( './../lib' ); - -var fcn; -var out; -var i; - -function add( x, y, z, w, t, s ) { - return x + y + z + w + t + s; -} - -fcn = curryRight( add ); -out = fcn; -for ( i = 0; i < add.length; i++ ) { - out = out( i*10 ); -} -console.log( out ); 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..462fc90 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@v0.1.0-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,s,i){var o,f;if(!e(n))throw new TypeError(t("1SN3c,J9",n));if(arguments.length<2){if(f=n.length,!r(f))throw new TypeError(t("1SNPG",f))}else if(arguments.length>2){if(o=i,!r(f=s))throw new TypeError(t("1SNAz,On",f))}else if(r(s))f=s;else{if(f=n.length,!r(f))throw new TypeError(t("1SNPG",f));o=s}return l([]);function l(e){return function(r){var t=e.slice();if(t.unshift(r),t.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNAz,On', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNPG', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","v","cargs","slice","unshift","apply"],"mappings":";;kTAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,WAAYP,IAE1C,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,SAEjC,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,WAAYH,SAEpC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvCD,EAAUF,CACV,CACD,OAAOU,EAAe,IAStB,SAASA,EAAeC,GACvB,OASA,SAAkBC,GACjB,IAAIC,EAAQF,EAAKG,QAEjB,GADAD,EAAME,QAASH,GACVC,EAAML,OAASL,EACnB,OAAOO,EAAeG,GAEvB,OAAOd,EAAIiB,MAAOd,EAASW,EAC3B,CACD,CACF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 7e7d2e8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform a function into a sequence of functions each accepting a single argument. -* -* @module @stdlib/utils-curry-right -* -* @example -* var curryRight = require( '@stdlib/utils-curry-right' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ - -// 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 4552bfd..0000000 --- a/lib/main.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* @param {Function} fcn - function to curry -* @param {PositiveInteger} [arity=fcn.length] - number of parameters -* @param {*} [thisArg] - evaluation context -* @throws {TypeError} first argument must be a function -* @throws {TypeError} first argument must be a function having at least one parameter -* @throws {TypeError} `arity` argument must be a positive integer -* @returns {Function} curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -function curryRight( fcn, arity, thisArg ) { - var context; - var len; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '1SN3c,J9', fcn ) ); - } - if ( arguments.length < 2 ) { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNPG', len ) ); - } - } else if ( arguments.length > 2 ) { - len = arity; - context = thisArg; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNAz,On', len ) ); - } - } else if ( isPositiveInteger( arity ) ) { - len = arity; - } else { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNPG', len ) ); - } - context = arity; - } - return createCurried( [] ); - - /** - * Returns a curry function. - * - * @private - * @param {Array} args - arguments - * @returns {Function} curry function - */ - function createCurried( args ) { - return curried; - - /** - * Curry function. - * - * @private - * @param {*} v - curried function parameter - * @returns {(Function|*)} partially applied curry function or curried function result - */ - function curried( v ) { - var cargs = args.slice(); - cargs.unshift( v ); - if ( cargs.length < len ) { - return createCurried( cargs ); - } - return fcn.apply( context, cargs ); - } - } -} - - -// EXPORTS // - -module.exports = curryRight; diff --git a/package.json b/package.json index c200d1b..206209e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Transform a function into a sequence of functions each accepting a single argument.", "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,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/assert-is-positive-integer": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/bench": "^0.1.0", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/random-base-randu": "^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..787c3d1 --- /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 36b2432..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,291 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var curryRight = require( './../../dist' ); - - -// FUNCTIONS // - -function add( x, y, z ) { - return x + y + z; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof curryRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (1 arg)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (2 args; context)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an arity argument which is not a positive integer (3 args)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - 0, - -1, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( add, value, {} ); - }; - } -}); - -tape( 'the function returns a function', function test( t ) { - var fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function curries a function', function test( t) { - var fcn; - var f; - - fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'for each invocation where the invocation number is less than the arity, the curried function returns a new partially applied curry function', function test( t ) { - var sum; - var f0; - var f1; - var f2; - - // Initial curried function has no partially applied arguments... - f0 = curryRight( add ); - - sum = f0( 1 )( 2 )( 3 ); - t.strictEqual( sum, 6, 'returns 6' ); - - sum = f0( 1 )( 3 )( 5 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f0( 10 )( 20 )( 40 ); - t.strictEqual( sum, 70, 'returns 70' ); - - // If arity greater than 1, first invocation returns a curried function with one partially applied argument... - f1 = f0( 2 ); - - sum = f1( 3 )( 4 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f1( 10 )( 20 ); - t.strictEqual( sum, 32, 'returns 32' ); - - sum = f1( -1 )( -2 ); - t.strictEqual( sum, -1, 'returns -1' ); - - // If arity greater than 2, second invocation returns a curried function with two partially applied arguments... - f2 = f1( 3 ); - - sum = f2( 5 ); - t.strictEqual( sum, 10, 'returns 10' ); - - sum = f2( 6 ); - t.strictEqual( sum, 11, 'returns 11' ); - - sum = f2( 10 ); - t.strictEqual( sum, 15, 'returns 15' ); - - // And so on and so forth... - - t.end(); -}); - -tape( 'the function supports specifying a function arity', function test( t ) { - var fcn; - var f; - - function add() { - return arguments[ 0 ] + arguments[ 1 ] + arguments[ 2 ]; - } - - fcn = curryRight( add, 3 ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'the function supports specifying a function context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate( length, units, type, color ) { - return this.style+': '+length+units+' '+type+' '+color; - } - }; - - fcn = curryRight( context.generate, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); - -tape( 'the function supports specifying a function arity and context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate() { - return this.style+': '+arguments[0]+arguments[1]+' '+arguments[2]+' '+arguments[3]; - } - }; - - fcn = curryRight( context.generate, 4, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index b455d23..0000000 --- a/test/test.js +++ /dev/null @@ -1,291 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var curryRight = require( './../lib' ); - - -// FUNCTIONS // - -function add( x, y, z ) { - return x + y + z; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof curryRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (1 arg)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (2 args; context)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an arity argument which is not a positive integer (3 args)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - 0, - -1, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( add, value, {} ); - }; - } -}); - -tape( 'the function returns a function', function test( t ) { - var fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function curries a function', function test( t) { - var fcn; - var f; - - fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'for each invocation where the invocation number is less than the arity, the curried function returns a new partially applied curry function', function test( t ) { - var sum; - var f0; - var f1; - var f2; - - // Initial curried function has no partially applied arguments... - f0 = curryRight( add ); - - sum = f0( 1 )( 2 )( 3 ); - t.strictEqual( sum, 6, 'returns 6' ); - - sum = f0( 1 )( 3 )( 5 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f0( 10 )( 20 )( 40 ); - t.strictEqual( sum, 70, 'returns 70' ); - - // If arity greater than 1, first invocation returns a curried function with one partially applied argument... - f1 = f0( 2 ); - - sum = f1( 3 )( 4 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f1( 10 )( 20 ); - t.strictEqual( sum, 32, 'returns 32' ); - - sum = f1( -1 )( -2 ); - t.strictEqual( sum, -1, 'returns -1' ); - - // If arity greater than 2, second invocation returns a curried function with two partially applied arguments... - f2 = f1( 3 ); - - sum = f2( 5 ); - t.strictEqual( sum, 10, 'returns 10' ); - - sum = f2( 6 ); - t.strictEqual( sum, 11, 'returns 11' ); - - sum = f2( 10 ); - t.strictEqual( sum, 15, 'returns 15' ); - - // And so on and so forth... - - t.end(); -}); - -tape( 'the function supports specifying a function arity', function test( t ) { - var fcn; - var f; - - function add() { - return arguments[ 0 ] + arguments[ 1 ] + arguments[ 2 ]; - } - - fcn = curryRight( add, 3 ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'the function supports specifying a function context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate( length, units, type, color ) { - return this.style+': '+length+units+' '+type+' '+color; - } - }; - - fcn = curryRight( context.generate, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); - -tape( 'the function supports specifying a function arity and context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate() { - return this.style+': '+arguments[0]+arguments[1]+' '+arguments[2]+' '+arguments[3]; - } - }; - - fcn = curryRight( context.generate, 4, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); From 0af8839a6c72ac6d70464fbb3f8f6c624c169059 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Nov 2023 07:24:34 +0000 Subject: [PATCH 067/140] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index 8d7768e..4552bfd 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -52,25 +52,25 @@ function curryRight( fcn, arity, thisArg ) { var context; var len; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '1SN3c,J9', fcn ) ); } if ( arguments.length < 2 ) { len = fcn.length; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); + throw new TypeError( format( '1SNPG', len ) ); } } else if ( arguments.length > 2 ) { len = arity; context = thisArg; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) ); + throw new TypeError( format( '1SNAz,On', len ) ); } } else if ( isPositiveInteger( arity ) ) { len = arity; } else { len = fcn.length; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); + throw new TypeError( format( '1SNPG', len ) ); } context = arity; } diff --git a/package.json b/package.json index 053bdd4..c200d1b 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-function": "^0.1.1", "@stdlib/assert-is-positive-integer": "^0.1.0", - "@stdlib/string-format": "^0.1.1" + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/bench": "^0.1.0", From be68e9a39c5cf86b70b870e86574f54320d449a7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 2 Nov 2023 12:01:53 +0000 Subject: [PATCH 068/140] Remove files --- index.d.ts | 82 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6264 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 ee0b7ce..0000000 --- a/index.d.ts +++ /dev/null @@ -1,82 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Curry function. -* -* @param v - curried function parameter -* @returns partially applied curry function or curried function result -*/ -type Closure = ( v: any ) => any; - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param arity - number of parameters -* @param thisArg - evaluation context -* @throws `arity` must be a positive integer -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight( fcn: Function, arity: number, thisArg?: any ): Closure; // tslint-disable-line max-line-length - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param thisArg - evaluation context -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight( fcn: Function, thisArg?: any ): Closure; - - -// EXPORTS // - -export = curryRight; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 462fc90..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@v0.1.0-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,s,i){var o,f;if(!e(n))throw new TypeError(t("1SN3c,J9",n));if(arguments.length<2){if(f=n.length,!r(f))throw new TypeError(t("1SNPG",f))}else if(arguments.length>2){if(o=i,!r(f=s))throw new TypeError(t("1SNAz,On",f))}else if(r(s))f=s;else{if(f=n.length,!r(f))throw new TypeError(t("1SNPG",f));o=s}return l([]);function l(e){return function(r){var t=e.slice();if(t.unshift(r),t.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNAz,On', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNPG', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","v","cargs","slice","unshift","apply"],"mappings":";;kTAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,WAAYP,IAE1C,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,SAEjC,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,WAAYH,SAEpC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvCD,EAAUF,CACV,CACD,OAAOU,EAAe,IAStB,SAASA,EAAeC,GACvB,OASA,SAAkBC,GACjB,IAAIC,EAAQF,EAAKG,QAEjB,GADAD,EAAME,QAASH,GACVC,EAAML,OAASL,EACnB,OAAOO,EAAeG,GAEvB,OAAOd,EAAIiB,MAAOd,EAASW,EAC3B,CACD,CACF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 787c3d1..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 609758803d1f8f454ab513d0caa17ed4420a5c65 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 2 Nov 2023 12:05:39 +0000 Subject: [PATCH 069/140] 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 | 39 +- benchmark/benchmark.js | 90 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 53 - docs/types/test.ts | 44 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 110 - package.json | 55 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 291 - 42 files changed, 6200 insertions(+), 4015 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 7353f6d..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-11-01T02:39:04.697Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2b7fad0..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/curry-right) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 9ffcfa1..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/curry-right) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 eb2ed9f..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: '6 18 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -258,7 +251,7 @@ console.log( out ); ## 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]. @@ -320,11 +313,11 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry +[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry/tree/esm -[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry +[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry/tree/esm -[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right +[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index fbb976c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isFunction = require( '@stdlib/assert-is-function' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var curryRight = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = curryRight( pow ); - if ( typeof out !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( out ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::returned_function', function benchmark( b ) { - var fcn; - var out; - var i; - - fcn = curryRight( pow ); - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = fcn( randu() )( randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::direct', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = pow( randu(), randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1f7cde2..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/curry-right" -%% click B href "https://github.com/stdlib-js/utils-curry-right/tree/main" -%% click C href "https://github.com/stdlib-js/utils-curry-right/tree/production" -%% click D href "https://github.com/stdlib-js/utils-curry-right/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-curry-right/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-curry-right/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/curry-right -[production-url]: https://github.com/stdlib-js/utils-curry-right/tree/production -[deno-url]: https://github.com/stdlib-js/utils-curry-right/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-curry-right/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-curry-right/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 8166962..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import curryRight from '../docs/types/index'; -export = curryRight; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 16477e0..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var g=f(function(b,o){ -var c=require('@stdlib/assert-is-function/dist'),n=require('@stdlib/assert-is-positive-integer/dist').isPrimitive,a=require('@stdlib/error-tools-fmtprodmsg/dist');function p(t,r,l){var u,e;if(!c(t))throw new TypeError(a('1SN3c',t));if(arguments.length<2){if(e=t.length,!n(e))throw new TypeError(a('1SNEX',e))}else if(arguments.length>2){if(e=r,u=l,!n(e))throw new TypeError(a('1SNAz',e))}else if(n(r))e=r;else{if(e=t.length,!n(e))throw new TypeError(a('1SNEX',e));u=r}return s([]);function s(m){return v;function v(h){var i=m.slice();return i.unshift(h),i.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = curryRight;\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* Transform a function into a sequence of functions each accepting a single argument.\n*\n* @module @stdlib/utils-curry-right\n*\n* @example\n* var curryRight = require( '@stdlib/utils-curry-right' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var f = curryRight( add );\n*\n* var sum = f( 2 )( 3 );\n* // returns 5\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,EAAoB,QAAS,oCAAqC,EAAE,YACpEC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,EAAYC,EAAKC,EAAOC,EAAU,CAC1C,IAAIC,EACAC,EACJ,GAAK,CAACR,EAAYI,CAAI,EACrB,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAI,CAAE,EAEzG,GAAK,UAAU,OAAS,GAEvB,GADAI,EAAMJ,EAAI,OACL,CAACH,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,kGAAmGM,CAAI,CAAE,UAE5H,UAAU,OAAS,GAG9B,GAFAA,EAAMH,EACNE,EAAUD,EACL,CAACL,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,4EAA6EM,CAAI,CAAE,UAEtGP,EAAmBI,CAAM,EACpCG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAI,OACL,CAACH,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,kGAAmGM,CAAI,CAAE,EAEvID,EAAUF,CACX,CACA,OAAOI,EAAe,CAAC,CAAE,EASzB,SAASA,EAAeC,EAAO,CAC9B,OAAOC,EASP,SAASA,EAASC,EAAI,CACrB,IAAIC,EAAQH,EAAK,MAAM,EAEvB,OADAG,EAAM,QAASD,CAAE,EACZC,EAAM,OAASL,EACZC,EAAeI,CAAM,EAEtBT,EAAI,MAAOG,EAASM,CAAM,CAClC,CACD,CACD,CAKAd,EAAO,QAAUI,ICrEjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isPositiveInteger", "format", "curryRight", "fcn", "arity", "thisArg", "context", "len", "createCurried", "args", "curried", "v", "cargs", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7271aed..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,53 +0,0 @@ - -{{alias}}( fcn[, arity][, thisArg] ) - Transforms a function into a sequence of functions each accepting a single - argument. - - Until return value resolution, each invocation returns a new partially - applied curry function. - - This function applies arguments starting from the right. - - Parameters - ---------- - fcn: Function - Function to curry. - - arity: integer (optional) - Number of parameters. Default: `fcn.length`. - - thisArg: any (optional) - Evaluation context. - - Returns - ------- - out: Function - Curry function. - - Examples - -------- - > function add( x, y ) { return x + y; }; - > var f = {{alias}}( add ); - > var sum = f( 2 )( 3 ) - 5 - - // Supply arity: - > function add() { return arguments[ 0 ] + arguments[ 1 ]; }; - > f = {{alias}}( add, 2 ); - > sum = f( 2 )( 3 ) - 5 - - // Provide function context: - > var obj = { - ... 'name': 'Ada', - ... 'greet': function greet( word1, word2 ) { - ... return word1 + ' ' + word2 + ', ' + this.name + '!' - ... } - ... }; - > f = {{alias}}( obj.greet, obj ); - > var str = f( 'there' )( 'Hello' ) - 'Hello there, Ada!' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a3b29c4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import curryRight = require( './index' ); - - -// TESTS // - -// The function returns a function... -{ - curryRight( ( x: number, y: number ): number => x + y ); // $ExpectType Closure - curryRight( ( x: number, y: number ): number => x + y, 2 ); // $ExpectType Closure - curryRight( ( x: number, y: number ): number => x + y, 2, {} ); // $ExpectType Closure -} - -// The compiler throws an error if the function is provided a first argument other than a function... -{ - curryRight( true ); // $ExpectError - curryRight( false ); // $ExpectError - curryRight( 5 ); // $ExpectError - curryRight( [] ); // $ExpectError - curryRight( {} ); // $ExpectError - curryRight( 'abc' ); // $ExpectError -} - -// The compiler throws an error if the function is provided more than three arguments... -{ - curryRight( ( x: number, y: number ): number => x + y, 2, {}, 4 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 76818ec..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 curryRight = require( './../lib' ); - -var fcn; -var out; -var i; - -function add( x, y, z, w, t, s ) { - return x + y + z + w + t + s; -} - -fcn = curryRight( add ); -out = fcn; -for ( i = 0; i < add.length; i++ ) { - out = out( i*10 ); -} -console.log( out ); 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..462fc90 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@v0.1.0-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,s,i){var o,f;if(!e(n))throw new TypeError(t("1SN3c,J9",n));if(arguments.length<2){if(f=n.length,!r(f))throw new TypeError(t("1SNPG",f))}else if(arguments.length>2){if(o=i,!r(f=s))throw new TypeError(t("1SNAz,On",f))}else if(r(s))f=s;else{if(f=n.length,!r(f))throw new TypeError(t("1SNPG",f));o=s}return l([]);function l(e){return function(r){var t=e.slice();if(t.unshift(r),t.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNAz,On', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNPG', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","v","cargs","slice","unshift","apply"],"mappings":";;kTAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,WAAYP,IAE1C,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,SAEjC,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,WAAYH,SAEpC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvCD,EAAUF,CACV,CACD,OAAOU,EAAe,IAStB,SAASA,EAAeC,GACvB,OASA,SAAkBC,GACjB,IAAIC,EAAQF,EAAKG,QAEjB,GADAD,EAAME,QAASH,GACVC,EAAML,OAASL,EACnB,OAAOO,EAAeG,GAEvB,OAAOd,EAAIiB,MAAOd,EAASW,EAC3B,CACD,CACF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 7e7d2e8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform a function into a sequence of functions each accepting a single argument. -* -* @module @stdlib/utils-curry-right -* -* @example -* var curryRight = require( '@stdlib/utils-curry-right' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ - -// 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 4552bfd..0000000 --- a/lib/main.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* @param {Function} fcn - function to curry -* @param {PositiveInteger} [arity=fcn.length] - number of parameters -* @param {*} [thisArg] - evaluation context -* @throws {TypeError} first argument must be a function -* @throws {TypeError} first argument must be a function having at least one parameter -* @throws {TypeError} `arity` argument must be a positive integer -* @returns {Function} curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -function curryRight( fcn, arity, thisArg ) { - var context; - var len; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '1SN3c,J9', fcn ) ); - } - if ( arguments.length < 2 ) { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNPG', len ) ); - } - } else if ( arguments.length > 2 ) { - len = arity; - context = thisArg; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNAz,On', len ) ); - } - } else if ( isPositiveInteger( arity ) ) { - len = arity; - } else { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNPG', len ) ); - } - context = arity; - } - return createCurried( [] ); - - /** - * Returns a curry function. - * - * @private - * @param {Array} args - arguments - * @returns {Function} curry function - */ - function createCurried( args ) { - return curried; - - /** - * Curry function. - * - * @private - * @param {*} v - curried function parameter - * @returns {(Function|*)} partially applied curry function or curried function result - */ - function curried( v ) { - var cargs = args.slice(); - cargs.unshift( v ); - if ( cargs.length < len ) { - return createCurried( cargs ); - } - return fcn.apply( context, cargs ); - } - } -} - - -// EXPORTS // - -module.exports = curryRight; diff --git a/package.json b/package.json index c200d1b..206209e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Transform a function into a sequence of functions each accepting a single argument.", "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,34 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-function": "^0.1.1", - "@stdlib/assert-is-positive-integer": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/bench": "^0.1.0", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/random-base-randu": "^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..6cf2583 --- /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 b455d23..0000000 --- a/test/test.js +++ /dev/null @@ -1,291 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var curryRight = require( './../lib' ); - - -// FUNCTIONS // - -function add( x, y, z ) { - return x + y + z; -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof curryRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (1 arg)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (2 args; context)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an arity argument which is not a positive integer (3 args)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - 0, - -1, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( add, value, {} ); - }; - } -}); - -tape( 'the function returns a function', function test( t ) { - var fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function curries a function', function test( t) { - var fcn; - var f; - - fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'for each invocation where the invocation number is less than the arity, the curried function returns a new partially applied curry function', function test( t ) { - var sum; - var f0; - var f1; - var f2; - - // Initial curried function has no partially applied arguments... - f0 = curryRight( add ); - - sum = f0( 1 )( 2 )( 3 ); - t.strictEqual( sum, 6, 'returns 6' ); - - sum = f0( 1 )( 3 )( 5 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f0( 10 )( 20 )( 40 ); - t.strictEqual( sum, 70, 'returns 70' ); - - // If arity greater than 1, first invocation returns a curried function with one partially applied argument... - f1 = f0( 2 ); - - sum = f1( 3 )( 4 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f1( 10 )( 20 ); - t.strictEqual( sum, 32, 'returns 32' ); - - sum = f1( -1 )( -2 ); - t.strictEqual( sum, -1, 'returns -1' ); - - // If arity greater than 2, second invocation returns a curried function with two partially applied arguments... - f2 = f1( 3 ); - - sum = f2( 5 ); - t.strictEqual( sum, 10, 'returns 10' ); - - sum = f2( 6 ); - t.strictEqual( sum, 11, 'returns 11' ); - - sum = f2( 10 ); - t.strictEqual( sum, 15, 'returns 15' ); - - // And so on and so forth... - - t.end(); -}); - -tape( 'the function supports specifying a function arity', function test( t ) { - var fcn; - var f; - - function add() { - return arguments[ 0 ] + arguments[ 1 ] + arguments[ 2 ]; - } - - fcn = curryRight( add, 3 ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'the function supports specifying a function context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate( length, units, type, color ) { - return this.style+': '+length+units+' '+type+' '+color; - } - }; - - fcn = curryRight( context.generate, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); - -tape( 'the function supports specifying a function arity and context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate() { - return this.style+': '+arguments[0]+arguments[1]+' '+arguments[2]+' '+arguments[3]; - } - }; - - fcn = curryRight( context.generate, 4, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); From 087a835db03d57db3ba280adba94abbc77a76251 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 21 Nov 2023 07:05:04 +0000 Subject: [PATCH 070/140] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index 8d7768e..4552bfd 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -52,25 +52,25 @@ function curryRight( fcn, arity, thisArg ) { var context; var len; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '1SN3c,J9', fcn ) ); } if ( arguments.length < 2 ) { len = fcn.length; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); + throw new TypeError( format( '1SNPG', len ) ); } } else if ( arguments.length > 2 ) { len = arity; context = thisArg; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) ); + throw new TypeError( format( '1SNAz,On', len ) ); } } else if ( isPositiveInteger( arity ) ) { len = arity; } else { len = fcn.length; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); + throw new TypeError( format( '1SNPG', len ) ); } context = arity; } diff --git a/package.json b/package.json index 156e5c5..6d11cc1 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-function": "^0.1.1", "@stdlib/assert-is-positive-integer": "^0.1.0", - "@stdlib/string-format": "^0.1.1" + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/bench": "^0.2.1", From a4e910a78b45ef9f483bf2e353699a369d728e20 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 21 Nov 2023 07:05:38 +0000 Subject: [PATCH 071/140] Remove files --- index.d.ts | 82 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6264 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 ee0b7ce..0000000 --- a/index.d.ts +++ /dev/null @@ -1,82 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Curry function. -* -* @param v - curried function parameter -* @returns partially applied curry function or curried function result -*/ -type Closure = ( v: any ) => any; - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param arity - number of parameters -* @param thisArg - evaluation context -* @throws `arity` must be a positive integer -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight( fcn: Function, arity: number, thisArg?: any ): Closure; // tslint-disable-line max-line-length - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param thisArg - evaluation context -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight( fcn: Function, thisArg?: any ): Closure; - - -// EXPORTS // - -export = curryRight; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 462fc90..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@v0.1.0-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,s,i){var o,f;if(!e(n))throw new TypeError(t("1SN3c,J9",n));if(arguments.length<2){if(f=n.length,!r(f))throw new TypeError(t("1SNPG",f))}else if(arguments.length>2){if(o=i,!r(f=s))throw new TypeError(t("1SNAz,On",f))}else if(r(s))f=s;else{if(f=n.length,!r(f))throw new TypeError(t("1SNPG",f));o=s}return l([]);function l(e){return function(r){var t=e.slice();if(t.unshift(r),t.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNAz,On', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNPG', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","v","cargs","slice","unshift","apply"],"mappings":";;kTAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,WAAYP,IAE1C,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,SAEjC,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,WAAYH,SAEpC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvCD,EAAUF,CACV,CACD,OAAOU,EAAe,IAStB,SAASA,EAAeC,GACvB,OASA,SAAkBC,GACjB,IAAIC,EAAQF,EAAKG,QAEjB,GADAD,EAAME,QAASH,GACVC,EAAML,OAASL,EACnB,OAAOO,EAAeG,GAEvB,OAAOd,EAAIiB,MAAOd,EAASW,EAC3B,CACD,CACF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 6cf2583..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 26916b291f7adf0ad9f9e121293e3e69db4139aa Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 21 Nov 2023 07:08:12 +0000 Subject: [PATCH 072/140] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 39 +- benchmark/benchmark.js | 90 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 53 - docs/types/test.ts | 44 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 110 - package.json | 56 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 285 - 41 files changed, 6200 insertions(+), 4009 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 2b7fad0..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/curry-right) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 9ffcfa1..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/curry-right) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 eb2ed9f..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: '6 18 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -258,7 +251,7 @@ console.log( out ); ## 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]. @@ -320,11 +313,11 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry +[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry/tree/esm -[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry +[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry/tree/esm -[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right +[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index fbb976c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isFunction = require( '@stdlib/assert-is-function' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var curryRight = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = curryRight( pow ); - if ( typeof out !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( out ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::returned_function', function benchmark( b ) { - var fcn; - var out; - var i; - - fcn = curryRight( pow ); - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = fcn( randu() )( randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::direct', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = pow( randu(), randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1f7cde2..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/curry-right" -%% click B href "https://github.com/stdlib-js/utils-curry-right/tree/main" -%% click C href "https://github.com/stdlib-js/utils-curry-right/tree/production" -%% click D href "https://github.com/stdlib-js/utils-curry-right/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-curry-right/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-curry-right/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/curry-right -[production-url]: https://github.com/stdlib-js/utils-curry-right/tree/production -[deno-url]: https://github.com/stdlib-js/utils-curry-right/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-curry-right/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-curry-right/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 8166962..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import curryRight from '../docs/types/index'; -export = curryRight; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 16477e0..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var g=f(function(b,o){ -var c=require('@stdlib/assert-is-function/dist'),n=require('@stdlib/assert-is-positive-integer/dist').isPrimitive,a=require('@stdlib/error-tools-fmtprodmsg/dist');function p(t,r,l){var u,e;if(!c(t))throw new TypeError(a('1SN3c',t));if(arguments.length<2){if(e=t.length,!n(e))throw new TypeError(a('1SNEX',e))}else if(arguments.length>2){if(e=r,u=l,!n(e))throw new TypeError(a('1SNAz',e))}else if(n(r))e=r;else{if(e=t.length,!n(e))throw new TypeError(a('1SNEX',e));u=r}return s([]);function s(m){return v;function v(h){var i=m.slice();return i.unshift(h),i.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = curryRight;\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* Transform a function into a sequence of functions each accepting a single argument.\n*\n* @module @stdlib/utils-curry-right\n*\n* @example\n* var curryRight = require( '@stdlib/utils-curry-right' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var f = curryRight( add );\n*\n* var sum = f( 2 )( 3 );\n* // returns 5\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,EAAoB,QAAS,oCAAqC,EAAE,YACpEC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,EAAYC,EAAKC,EAAOC,EAAU,CAC1C,IAAIC,EACAC,EACJ,GAAK,CAACR,EAAYI,CAAI,EACrB,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAI,CAAE,EAEzG,GAAK,UAAU,OAAS,GAEvB,GADAI,EAAMJ,EAAI,OACL,CAACH,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,kGAAmGM,CAAI,CAAE,UAE5H,UAAU,OAAS,GAG9B,GAFAA,EAAMH,EACNE,EAAUD,EACL,CAACL,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,4EAA6EM,CAAI,CAAE,UAEtGP,EAAmBI,CAAM,EACpCG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAI,OACL,CAACH,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,kGAAmGM,CAAI,CAAE,EAEvID,EAAUF,CACX,CACA,OAAOI,EAAe,CAAC,CAAE,EASzB,SAASA,EAAeC,EAAO,CAC9B,OAAOC,EASP,SAASA,EAASC,EAAI,CACrB,IAAIC,EAAQH,EAAK,MAAM,EAEvB,OADAG,EAAM,QAASD,CAAE,EACZC,EAAM,OAASL,EACZC,EAAeI,CAAM,EAEtBT,EAAI,MAAOG,EAASM,CAAM,CAClC,CACD,CACD,CAKAd,EAAO,QAAUI,ICrEjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isPositiveInteger", "format", "curryRight", "fcn", "arity", "thisArg", "context", "len", "createCurried", "args", "curried", "v", "cargs", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7271aed..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,53 +0,0 @@ - -{{alias}}( fcn[, arity][, thisArg] ) - Transforms a function into a sequence of functions each accepting a single - argument. - - Until return value resolution, each invocation returns a new partially - applied curry function. - - This function applies arguments starting from the right. - - Parameters - ---------- - fcn: Function - Function to curry. - - arity: integer (optional) - Number of parameters. Default: `fcn.length`. - - thisArg: any (optional) - Evaluation context. - - Returns - ------- - out: Function - Curry function. - - Examples - -------- - > function add( x, y ) { return x + y; }; - > var f = {{alias}}( add ); - > var sum = f( 2 )( 3 ) - 5 - - // Supply arity: - > function add() { return arguments[ 0 ] + arguments[ 1 ]; }; - > f = {{alias}}( add, 2 ); - > sum = f( 2 )( 3 ) - 5 - - // Provide function context: - > var obj = { - ... 'name': 'Ada', - ... 'greet': function greet( word1, word2 ) { - ... return word1 + ' ' + word2 + ', ' + this.name + '!' - ... } - ... }; - > f = {{alias}}( obj.greet, obj ); - > var str = f( 'there' )( 'Hello' ) - 'Hello there, Ada!' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a3b29c4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import curryRight = require( './index' ); - - -// TESTS // - -// The function returns a function... -{ - curryRight( ( x: number, y: number ): number => x + y ); // $ExpectType Closure - curryRight( ( x: number, y: number ): number => x + y, 2 ); // $ExpectType Closure - curryRight( ( x: number, y: number ): number => x + y, 2, {} ); // $ExpectType Closure -} - -// The compiler throws an error if the function is provided a first argument other than a function... -{ - curryRight( true ); // $ExpectError - curryRight( false ); // $ExpectError - curryRight( 5 ); // $ExpectError - curryRight( [] ); // $ExpectError - curryRight( {} ); // $ExpectError - curryRight( 'abc' ); // $ExpectError -} - -// The compiler throws an error if the function is provided more than three arguments... -{ - curryRight( ( x: number, y: number ): number => x + y, 2, {}, 4 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 76818ec..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 curryRight = require( './../lib' ); - -var fcn; -var out; -var i; - -function add( x, y, z, w, t, s ) { - return x + y + z + w + t + s; -} - -fcn = curryRight( add ); -out = fcn; -for ( i = 0; i < add.length; i++ ) { - out = out( i*10 ); -} -console.log( out ); 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..462fc90 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@v0.1.0-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,s,i){var o,f;if(!e(n))throw new TypeError(t("1SN3c,J9",n));if(arguments.length<2){if(f=n.length,!r(f))throw new TypeError(t("1SNPG",f))}else if(arguments.length>2){if(o=i,!r(f=s))throw new TypeError(t("1SNAz,On",f))}else if(r(s))f=s;else{if(f=n.length,!r(f))throw new TypeError(t("1SNPG",f));o=s}return l([]);function l(e){return function(r){var t=e.slice();if(t.unshift(r),t.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNAz,On', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNPG', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","v","cargs","slice","unshift","apply"],"mappings":";;kTAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,WAAYP,IAE1C,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,SAEjC,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,WAAYH,SAEpC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvCD,EAAUF,CACV,CACD,OAAOU,EAAe,IAStB,SAASA,EAAeC,GACvB,OASA,SAAkBC,GACjB,IAAIC,EAAQF,EAAKG,QAEjB,GADAD,EAAME,QAASH,GACVC,EAAML,OAASL,EACnB,OAAOO,EAAeG,GAEvB,OAAOd,EAAIiB,MAAOd,EAASW,EAC3B,CACD,CACF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 7e7d2e8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform a function into a sequence of functions each accepting a single argument. -* -* @module @stdlib/utils-curry-right -* -* @example -* var curryRight = require( '@stdlib/utils-curry-right' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ - -// 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 4552bfd..0000000 --- a/lib/main.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* @param {Function} fcn - function to curry -* @param {PositiveInteger} [arity=fcn.length] - number of parameters -* @param {*} [thisArg] - evaluation context -* @throws {TypeError} first argument must be a function -* @throws {TypeError} first argument must be a function having at least one parameter -* @throws {TypeError} `arity` argument must be a positive integer -* @returns {Function} curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -function curryRight( fcn, arity, thisArg ) { - var context; - var len; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '1SN3c,J9', fcn ) ); - } - if ( arguments.length < 2 ) { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNPG', len ) ); - } - } else if ( arguments.length > 2 ) { - len = arity; - context = thisArg; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNAz,On', len ) ); - } - } else if ( isPositiveInteger( arity ) ) { - len = arity; - } else { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNPG', len ) ); - } - context = arity; - } - return createCurried( [] ); - - /** - * Returns a curry function. - * - * @private - * @param {Array} args - arguments - * @returns {Function} curry function - */ - function createCurried( args ) { - return curried; - - /** - * Curry function. - * - * @private - * @param {*} v - curried function parameter - * @returns {(Function|*)} partially applied curry function or curried function result - */ - function curried( v ) { - var cargs = args.slice(); - cargs.unshift( v ); - if ( cargs.length < len ) { - return createCurried( cargs ); - } - return fcn.apply( context, cargs ); - } - } -} - - -// EXPORTS // - -module.exports = curryRight; diff --git a/package.json b/package.json index 6d11cc1..206209e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Transform a function into a sequence of functions each accepting a single argument.", "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/assert-is-positive-integer": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/bench": "^0.2.1", - "@stdlib/math-base-ops-add3": "github:stdlib-js/math-base-ops-add3#main", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/random-base-randu": "^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..db11da6 --- /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 3f1273f..0000000 --- a/test/test.js +++ /dev/null @@ -1,285 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var add = require( '@stdlib/math-base-ops-add3' ); -var curryRight = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof curryRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (1 arg)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (2 args; context)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an arity argument which is not a positive integer (3 args)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - 0, - -1, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( add, value, {} ); - }; - } -}); - -tape( 'the function returns a function', function test( t ) { - var fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function curries a function', function test( t) { - var fcn; - var f; - - fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'for each invocation where the invocation number is less than the arity, the curried function returns a new partially applied curry function', function test( t ) { - var sum; - var f0; - var f1; - var f2; - - // Initial curried function has no partially applied arguments... - f0 = curryRight( add ); - - sum = f0( 1 )( 2 )( 3 ); - t.strictEqual( sum, 6, 'returns 6' ); - - sum = f0( 1 )( 3 )( 5 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f0( 10 )( 20 )( 40 ); - t.strictEqual( sum, 70, 'returns 70' ); - - // If arity greater than 1, first invocation returns a curried function with one partially applied argument... - f1 = f0( 2 ); - - sum = f1( 3 )( 4 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f1( 10 )( 20 ); - t.strictEqual( sum, 32, 'returns 32' ); - - sum = f1( -1 )( -2 ); - t.strictEqual( sum, -1, 'returns -1' ); - - // If arity greater than 2, second invocation returns a curried function with two partially applied arguments... - f2 = f1( 3 ); - - sum = f2( 5 ); - t.strictEqual( sum, 10, 'returns 10' ); - - sum = f2( 6 ); - t.strictEqual( sum, 11, 'returns 11' ); - - sum = f2( 10 ); - t.strictEqual( sum, 15, 'returns 15' ); - - // And so on and so forth... - - t.end(); -}); - -tape( 'the function supports specifying a function arity', function test( t ) { - var fcn; - var f; - - function add() { - return arguments[ 0 ] + arguments[ 1 ] + arguments[ 2 ]; - } - - fcn = curryRight( add, 3 ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'the function supports specifying a function context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate( length, units, type, color ) { - return this.style+': '+length+units+' '+type+' '+color; - } - }; - - fcn = curryRight( context.generate, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); - -tape( 'the function supports specifying a function arity and context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate() { - return this.style+': '+arguments[0]+arguments[1]+' '+arguments[2]+' '+arguments[3]; - } - }; - - fcn = curryRight( context.generate, 4, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); From e34f6f58351586717807d33b9f91fbe9d83e5e28 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Dec 2023 06:22:19 +0000 Subject: [PATCH 073/140] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index 8d7768e..4552bfd 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -52,25 +52,25 @@ function curryRight( fcn, arity, thisArg ) { var context; var len; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '1SN3c,J9', fcn ) ); } if ( arguments.length < 2 ) { len = fcn.length; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); + throw new TypeError( format( '1SNPG', len ) ); } } else if ( arguments.length > 2 ) { len = arity; context = thisArg; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) ); + throw new TypeError( format( '1SNAz,On', len ) ); } } else if ( isPositiveInteger( arity ) ) { len = arity; } else { len = fcn.length; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); + throw new TypeError( format( '1SNPG', len ) ); } context = arity; } diff --git a/package.json b/package.json index cdcaede..482ae80 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-function": "^0.1.1", "@stdlib/assert-is-positive-integer": "^0.1.0", - "@stdlib/string-format": "^0.1.1" + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/bench": "^0.2.1", From 32db8ab15698b8b555afdea219fe2a9a802465d9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Dec 2023 00:48:49 +0000 Subject: [PATCH 074/140] Remove files --- index.d.ts | 82 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6264 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 a9f71aa..0000000 --- a/index.d.ts +++ /dev/null @@ -1,82 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Curry function. -* -* @param v - curried function parameter -* @returns partially applied curry function or curried function result -*/ -type Closure = ( v: any ) => any; - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param arity - number of parameters -* @param thisArg - evaluation context -* @throws `arity` must be a positive integer -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight( fcn: Function, arity: number, thisArg?: any ): Closure; - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param thisArg - evaluation context -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight( fcn: Function, thisArg?: any ): Closure; - - -// EXPORTS // - -export = curryRight; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 462fc90..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@v0.1.0-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,s,i){var o,f;if(!e(n))throw new TypeError(t("1SN3c,J9",n));if(arguments.length<2){if(f=n.length,!r(f))throw new TypeError(t("1SNPG",f))}else if(arguments.length>2){if(o=i,!r(f=s))throw new TypeError(t("1SNAz,On",f))}else if(r(s))f=s;else{if(f=n.length,!r(f))throw new TypeError(t("1SNPG",f));o=s}return l([]);function l(e){return function(r){var t=e.slice();if(t.unshift(r),t.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNAz,On', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNPG', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","v","cargs","slice","unshift","apply"],"mappings":";;kTAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,WAAYP,IAE1C,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,SAEjC,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,WAAYH,SAEpC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvCD,EAAUF,CACV,CACD,OAAOU,EAAe,IAStB,SAASA,EAAeC,GACvB,OASA,SAAkBC,GACjB,IAAIC,EAAQF,EAAKG,QAEjB,GADAD,EAAME,QAASH,GACVC,EAAML,OAASL,EACnB,OAAOO,EAAeG,GAEvB,OAAOd,EAAIiB,MAAOd,EAASW,EAC3B,CACD,CACF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index db11da6..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 69096ec1b41a555f785261e9c610647551a8e7a1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Dec 2023 00:51:35 +0000 Subject: [PATCH 075/140] 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 | 39 +- benchmark/benchmark.js | 90 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 53 - docs/types/test.ts | 44 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 110 - package.json | 56 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 285 - 42 files changed, 6200 insertions(+), 4005 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 243dbeb..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-12-01T02:48:54.644Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2b7fad0..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/curry-right) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 9ffcfa1..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/curry-right) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 eb2ed9f..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: '6 18 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -258,7 +251,7 @@ console.log( out ); ## 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]. @@ -320,11 +313,11 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry +[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry/tree/esm -[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry +[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry/tree/esm -[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right +[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index fbb976c..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isFunction = require( '@stdlib/assert-is-function' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var curryRight = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = curryRight( pow ); - if ( typeof out !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( out ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::returned_function', function benchmark( b ) { - var fcn; - var out; - var i; - - fcn = curryRight( pow ); - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = fcn( randu() )( randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::direct', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = pow( randu(), randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1f7cde2..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/curry-right" -%% click B href "https://github.com/stdlib-js/utils-curry-right/tree/main" -%% click C href "https://github.com/stdlib-js/utils-curry-right/tree/production" -%% click D href "https://github.com/stdlib-js/utils-curry-right/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-curry-right/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-curry-right/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/curry-right -[production-url]: https://github.com/stdlib-js/utils-curry-right/tree/production -[deno-url]: https://github.com/stdlib-js/utils-curry-right/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-curry-right/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-curry-right/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 8166962..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import curryRight from '../docs/types/index'; -export = curryRight; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 16477e0..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var g=f(function(b,o){ -var c=require('@stdlib/assert-is-function/dist'),n=require('@stdlib/assert-is-positive-integer/dist').isPrimitive,a=require('@stdlib/error-tools-fmtprodmsg/dist');function p(t,r,l){var u,e;if(!c(t))throw new TypeError(a('1SN3c',t));if(arguments.length<2){if(e=t.length,!n(e))throw new TypeError(a('1SNEX',e))}else if(arguments.length>2){if(e=r,u=l,!n(e))throw new TypeError(a('1SNAz',e))}else if(n(r))e=r;else{if(e=t.length,!n(e))throw new TypeError(a('1SNEX',e));u=r}return s([]);function s(m){return v;function v(h){var i=m.slice();return i.unshift(h),i.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = curryRight;\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* Transform a function into a sequence of functions each accepting a single argument.\n*\n* @module @stdlib/utils-curry-right\n*\n* @example\n* var curryRight = require( '@stdlib/utils-curry-right' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var f = curryRight( add );\n*\n* var sum = f( 2 )( 3 );\n* // returns 5\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,EAAoB,QAAS,oCAAqC,EAAE,YACpEC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,EAAYC,EAAKC,EAAOC,EAAU,CAC1C,IAAIC,EACAC,EACJ,GAAK,CAACR,EAAYI,CAAI,EACrB,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAI,CAAE,EAEzG,GAAK,UAAU,OAAS,GAEvB,GADAI,EAAMJ,EAAI,OACL,CAACH,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,kGAAmGM,CAAI,CAAE,UAE5H,UAAU,OAAS,GAG9B,GAFAA,EAAMH,EACNE,EAAUD,EACL,CAACL,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,4EAA6EM,CAAI,CAAE,UAEtGP,EAAmBI,CAAM,EACpCG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAI,OACL,CAACH,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,kGAAmGM,CAAI,CAAE,EAEvID,EAAUF,CACX,CACA,OAAOI,EAAe,CAAC,CAAE,EASzB,SAASA,EAAeC,EAAO,CAC9B,OAAOC,EASP,SAASA,EAASC,EAAI,CACrB,IAAIC,EAAQH,EAAK,MAAM,EAEvB,OADAG,EAAM,QAASD,CAAE,EACZC,EAAM,OAASL,EACZC,EAAeI,CAAM,EAEtBT,EAAI,MAAOG,EAASM,CAAM,CAClC,CACD,CACD,CAKAd,EAAO,QAAUI,ICrEjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isPositiveInteger", "format", "curryRight", "fcn", "arity", "thisArg", "context", "len", "createCurried", "args", "curried", "v", "cargs", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7271aed..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,53 +0,0 @@ - -{{alias}}( fcn[, arity][, thisArg] ) - Transforms a function into a sequence of functions each accepting a single - argument. - - Until return value resolution, each invocation returns a new partially - applied curry function. - - This function applies arguments starting from the right. - - Parameters - ---------- - fcn: Function - Function to curry. - - arity: integer (optional) - Number of parameters. Default: `fcn.length`. - - thisArg: any (optional) - Evaluation context. - - Returns - ------- - out: Function - Curry function. - - Examples - -------- - > function add( x, y ) { return x + y; }; - > var f = {{alias}}( add ); - > var sum = f( 2 )( 3 ) - 5 - - // Supply arity: - > function add() { return arguments[ 0 ] + arguments[ 1 ]; }; - > f = {{alias}}( add, 2 ); - > sum = f( 2 )( 3 ) - 5 - - // Provide function context: - > var obj = { - ... 'name': 'Ada', - ... 'greet': function greet( word1, word2 ) { - ... return word1 + ' ' + word2 + ', ' + this.name + '!' - ... } - ... }; - > f = {{alias}}( obj.greet, obj ); - > var str = f( 'there' )( 'Hello' ) - 'Hello there, Ada!' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index a3b29c4..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import curryRight = require( './index' ); - - -// TESTS // - -// The function returns a function... -{ - curryRight( ( x: number, y: number ): number => x + y ); // $ExpectType Closure - curryRight( ( x: number, y: number ): number => x + y, 2 ); // $ExpectType Closure - curryRight( ( x: number, y: number ): number => x + y, 2, {} ); // $ExpectType Closure -} - -// The compiler throws an error if the function is provided a first argument other than a function... -{ - curryRight( true ); // $ExpectError - curryRight( false ); // $ExpectError - curryRight( 5 ); // $ExpectError - curryRight( [] ); // $ExpectError - curryRight( {} ); // $ExpectError - curryRight( 'abc' ); // $ExpectError -} - -// The compiler throws an error if the function is provided more than three arguments... -{ - curryRight( ( x: number, y: number ): number => x + y, 2, {}, 4 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 76818ec..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 curryRight = require( './../lib' ); - -var fcn; -var out; -var i; - -function add( x, y, z, w, t, s ) { - return x + y + z + w + t + s; -} - -fcn = curryRight( add ); -out = fcn; -for ( i = 0; i < add.length; i++ ) { - out = out( i*10 ); -} -console.log( out ); 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..462fc90 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@v0.1.0-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,s,i){var o,f;if(!e(n))throw new TypeError(t("1SN3c,J9",n));if(arguments.length<2){if(f=n.length,!r(f))throw new TypeError(t("1SNPG",f))}else if(arguments.length>2){if(o=i,!r(f=s))throw new TypeError(t("1SNAz,On",f))}else if(r(s))f=s;else{if(f=n.length,!r(f))throw new TypeError(t("1SNPG",f));o=s}return l([]);function l(e){return function(r){var t=e.slice();if(t.unshift(r),t.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNAz,On', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNPG', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","v","cargs","slice","unshift","apply"],"mappings":";;kTAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,WAAYP,IAE1C,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,SAEjC,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,WAAYH,SAEpC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvCD,EAAUF,CACV,CACD,OAAOU,EAAe,IAStB,SAASA,EAAeC,GACvB,OASA,SAAkBC,GACjB,IAAIC,EAAQF,EAAKG,QAEjB,GADAD,EAAME,QAASH,GACVC,EAAML,OAASL,EACnB,OAAOO,EAAeG,GAEvB,OAAOd,EAAIiB,MAAOd,EAASW,EAC3B,CACD,CACF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 7e7d2e8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform a function into a sequence of functions each accepting a single argument. -* -* @module @stdlib/utils-curry-right -* -* @example -* var curryRight = require( '@stdlib/utils-curry-right' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ - -// 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 4552bfd..0000000 --- a/lib/main.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* @param {Function} fcn - function to curry -* @param {PositiveInteger} [arity=fcn.length] - number of parameters -* @param {*} [thisArg] - evaluation context -* @throws {TypeError} first argument must be a function -* @throws {TypeError} first argument must be a function having at least one parameter -* @throws {TypeError} `arity` argument must be a positive integer -* @returns {Function} curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -function curryRight( fcn, arity, thisArg ) { - var context; - var len; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '1SN3c,J9', fcn ) ); - } - if ( arguments.length < 2 ) { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNPG', len ) ); - } - } else if ( arguments.length > 2 ) { - len = arity; - context = thisArg; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNAz,On', len ) ); - } - } else if ( isPositiveInteger( arity ) ) { - len = arity; - } else { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNPG', len ) ); - } - context = arity; - } - return createCurried( [] ); - - /** - * Returns a curry function. - * - * @private - * @param {Array} args - arguments - * @returns {Function} curry function - */ - function createCurried( args ) { - return curried; - - /** - * Curry function. - * - * @private - * @param {*} v - curried function parameter - * @returns {(Function|*)} partially applied curry function or curried function result - */ - function curried( v ) { - var cargs = args.slice(); - cargs.unshift( v ); - if ( cargs.length < len ) { - return createCurried( cargs ); - } - return fcn.apply( context, cargs ); - } - } -} - - -// EXPORTS // - -module.exports = curryRight; diff --git a/package.json b/package.json index 482ae80..206209e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Transform a function into a sequence of functions each accepting a single argument.", "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/assert-is-positive-integer": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/bench": "^0.2.1", - "@stdlib/math-base-ops-add3": "^0.1.0", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/random-base-randu": "^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..6b74b04 --- /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 3f1273f..0000000 --- a/test/test.js +++ /dev/null @@ -1,285 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var add = require( '@stdlib/math-base-ops-add3' ); -var curryRight = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof curryRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (1 arg)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (2 args; context)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an arity argument which is not a positive integer (3 args)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - 0, - -1, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( add, value, {} ); - }; - } -}); - -tape( 'the function returns a function', function test( t ) { - var fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function curries a function', function test( t) { - var fcn; - var f; - - fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'for each invocation where the invocation number is less than the arity, the curried function returns a new partially applied curry function', function test( t ) { - var sum; - var f0; - var f1; - var f2; - - // Initial curried function has no partially applied arguments... - f0 = curryRight( add ); - - sum = f0( 1 )( 2 )( 3 ); - t.strictEqual( sum, 6, 'returns 6' ); - - sum = f0( 1 )( 3 )( 5 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f0( 10 )( 20 )( 40 ); - t.strictEqual( sum, 70, 'returns 70' ); - - // If arity greater than 1, first invocation returns a curried function with one partially applied argument... - f1 = f0( 2 ); - - sum = f1( 3 )( 4 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f1( 10 )( 20 ); - t.strictEqual( sum, 32, 'returns 32' ); - - sum = f1( -1 )( -2 ); - t.strictEqual( sum, -1, 'returns -1' ); - - // If arity greater than 2, second invocation returns a curried function with two partially applied arguments... - f2 = f1( 3 ); - - sum = f2( 5 ); - t.strictEqual( sum, 10, 'returns 10' ); - - sum = f2( 6 ); - t.strictEqual( sum, 11, 'returns 11' ); - - sum = f2( 10 ); - t.strictEqual( sum, 15, 'returns 15' ); - - // And so on and so forth... - - t.end(); -}); - -tape( 'the function supports specifying a function arity', function test( t ) { - var fcn; - var f; - - function add() { - return arguments[ 0 ] + arguments[ 1 ] + arguments[ 2 ]; - } - - fcn = curryRight( add, 3 ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'the function supports specifying a function context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate( length, units, type, color ) { - return this.style+': '+length+units+' '+type+' '+color; - } - }; - - fcn = curryRight( context.generate, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); - -tape( 'the function supports specifying a function arity and context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate() { - return this.style+': '+arguments[0]+arguments[1]+' '+arguments[2]+' '+arguments[3]; - } - }; - - fcn = curryRight( context.generate, 4, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); From 274f0e1a04bff300427458591ac3b9be14713779 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 30 Dec 2023 23:05:38 +0000 Subject: [PATCH 076/140] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a760519..779c22d 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-function": "^0.1.1", "@stdlib/assert-is-positive-integer": "^0.1.0", - "@stdlib/string-format": "^0.1.1" + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/math-base-ops-add3": "^0.1.0", From 40844802deb049aba0e9c1a48c4f9066ea2bffd2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 30 Dec 2023 23:06:09 +0000 Subject: [PATCH 077/140] Remove files --- index.d.ts | 82 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6264 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 a9f71aa..0000000 --- a/index.d.ts +++ /dev/null @@ -1,82 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Curry function. -* -* @param v - curried function parameter -* @returns partially applied curry function or curried function result -*/ -type Closure = ( v: any ) => any; - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param arity - number of parameters -* @param thisArg - evaluation context -* @throws `arity` must be a positive integer -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight( fcn: Function, arity: number, thisArg?: any ): Closure; - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param thisArg - evaluation context -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight( fcn: Function, thisArg?: any ): Closure; - - -// EXPORTS // - -export = curryRight; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 462fc90..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@v0.1.0-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,s,i){var o,f;if(!e(n))throw new TypeError(t("1SN3c,J9",n));if(arguments.length<2){if(f=n.length,!r(f))throw new TypeError(t("1SNPG",f))}else if(arguments.length>2){if(o=i,!r(f=s))throw new TypeError(t("1SNAz,On",f))}else if(r(s))f=s;else{if(f=n.length,!r(f))throw new TypeError(t("1SNPG",f));o=s}return l([]);function l(e){return function(r){var t=e.slice();if(t.unshift(r),t.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNAz,On', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNPG', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","v","cargs","slice","unshift","apply"],"mappings":";;kTAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,WAAYP,IAE1C,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,SAEjC,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,WAAYH,SAEpC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvCD,EAAUF,CACV,CACD,OAAOU,EAAe,IAStB,SAASA,EAAeC,GACvB,OASA,SAAkBC,GACjB,IAAIC,EAAQF,EAAKG,QAEjB,GADAD,EAAME,QAASH,GACVC,EAAML,OAASL,EACnB,OAAOO,EAAeG,GAEvB,OAAOd,EAAIiB,MAAOd,EAASW,EAC3B,CACD,CACF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 6b74b04..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From ae27851cabe92c8d7eb3253e2db981cb5892bd47 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 30 Dec 2023 23:06:34 +0000 Subject: [PATCH 078/140] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 90 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 53 - docs/types/test.ts | 71 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 110 - package.json | 56 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 285 - 42 files changed, 6200 insertions(+), 4037 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 2b7fad0..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/curry-right) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 9ffcfa1..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/curry-right) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 4887107..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: '6 18 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index e1e3539..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -258,7 +251,7 @@ console.log( out ); ## 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]. @@ -320,11 +313,11 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry +[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry/tree/esm -[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry +[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry/tree/esm -[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right +[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right/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 69ca868..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isFunction = require( '@stdlib/assert-is-function' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var curryRight = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = curryRight( pow ); - if ( typeof out !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( out ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::returned_function', function benchmark( b ) { - var fcn; - var out; - var i; - - fcn = curryRight( pow ); - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = fcn( randu() )( randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::direct', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = pow( randu(), randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1f7cde2..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/curry-right" -%% click B href "https://github.com/stdlib-js/utils-curry-right/tree/main" -%% click C href "https://github.com/stdlib-js/utils-curry-right/tree/production" -%% click D href "https://github.com/stdlib-js/utils-curry-right/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-curry-right/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-curry-right/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/curry-right -[production-url]: https://github.com/stdlib-js/utils-curry-right/tree/production -[deno-url]: https://github.com/stdlib-js/utils-curry-right/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-curry-right/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-curry-right/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 8166962..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import curryRight from '../docs/types/index'; -export = curryRight; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 16477e0..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var g=f(function(b,o){ -var c=require('@stdlib/assert-is-function/dist'),n=require('@stdlib/assert-is-positive-integer/dist').isPrimitive,a=require('@stdlib/error-tools-fmtprodmsg/dist');function p(t,r,l){var u,e;if(!c(t))throw new TypeError(a('1SN3c',t));if(arguments.length<2){if(e=t.length,!n(e))throw new TypeError(a('1SNEX',e))}else if(arguments.length>2){if(e=r,u=l,!n(e))throw new TypeError(a('1SNAz',e))}else if(n(r))e=r;else{if(e=t.length,!n(e))throw new TypeError(a('1SNEX',e));u=r}return s([]);function s(m){return v;function v(h){var i=m.slice();return i.unshift(h),i.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = curryRight;\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* Transform a function into a sequence of functions each accepting a single argument.\n*\n* @module @stdlib/utils-curry-right\n*\n* @example\n* var curryRight = require( '@stdlib/utils-curry-right' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var f = curryRight( add );\n*\n* var sum = f( 2 )( 3 );\n* // returns 5\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,EAAoB,QAAS,oCAAqC,EAAE,YACpEC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,EAAYC,EAAKC,EAAOC,EAAU,CAC1C,IAAIC,EACAC,EACJ,GAAK,CAACR,EAAYI,CAAI,EACrB,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAI,CAAE,EAEzG,GAAK,UAAU,OAAS,GAEvB,GADAI,EAAMJ,EAAI,OACL,CAACH,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,kGAAmGM,CAAI,CAAE,UAE5H,UAAU,OAAS,GAG9B,GAFAA,EAAMH,EACNE,EAAUD,EACL,CAACL,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,4EAA6EM,CAAI,CAAE,UAEtGP,EAAmBI,CAAM,EACpCG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAI,OACL,CAACH,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,kGAAmGM,CAAI,CAAE,EAEvID,EAAUF,CACX,CACA,OAAOI,EAAe,CAAC,CAAE,EASzB,SAASA,EAAeC,EAAO,CAC9B,OAAOC,EASP,SAASA,EAASC,EAAI,CACrB,IAAIC,EAAQH,EAAK,MAAM,EAEvB,OADAG,EAAM,QAASD,CAAE,EACZC,EAAM,OAASL,EACZC,EAAeI,CAAM,EAEtBT,EAAI,MAAOG,EAASM,CAAM,CAClC,CACD,CACD,CAKAd,EAAO,QAAUI,ICrEjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isPositiveInteger", "format", "curryRight", "fcn", "arity", "thisArg", "context", "len", "createCurried", "args", "curried", "v", "cargs", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7271aed..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,53 +0,0 @@ - -{{alias}}( fcn[, arity][, thisArg] ) - Transforms a function into a sequence of functions each accepting a single - argument. - - Until return value resolution, each invocation returns a new partially - applied curry function. - - This function applies arguments starting from the right. - - Parameters - ---------- - fcn: Function - Function to curry. - - arity: integer (optional) - Number of parameters. Default: `fcn.length`. - - thisArg: any (optional) - Evaluation context. - - Returns - ------- - out: Function - Curry function. - - Examples - -------- - > function add( x, y ) { return x + y; }; - > var f = {{alias}}( add ); - > var sum = f( 2 )( 3 ) - 5 - - // Supply arity: - > function add() { return arguments[ 0 ] + arguments[ 1 ]; }; - > f = {{alias}}( add, 2 ); - > sum = f( 2 )( 3 ) - 5 - - // Provide function context: - > var obj = { - ... 'name': 'Ada', - ... 'greet': function greet( word1, word2 ) { - ... return word1 + ' ' + word2 + ', ' + this.name + '!' - ... } - ... }; - > f = {{alias}}( obj.greet, obj ); - > var str = f( 'there' )( 'Hello' ) - 'Hello there, Ada!' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4577cdb..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,71 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import curryRight = require( './index' ); - - -// TESTS // - -// The function returns a function... -{ - curryRight( ( x: number, y: number ): number => x + y ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: number, y: number ): number => x + y, 2 ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: number, y: number ): number => x + y, 2, {} ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: string, y: string ): string => x + y, {} ); // $ExpectType (v: string) => (v: string) => string - curryRight( ( x: string, y: string ): string => x + y, 2, {} ); // $ExpectType (v: string) => (v: string) => string - curryRight( ( str: string, n: number ): string => str.substring( n ) ); // $ExpectType (v: number) => (v: string) => string - - const cxt = { - 'count': 0, - 'multiply': function multiply( this: { count: number }, x: number, y: number ): number { - this.count += 1; // eslint-disable-line no-invalid-this - return x * y; - } - }; - curryRight( cxt.multiply ); // $ExpectType (v: number) => (v: number) => number - curryRight( cxt.multiply, 2 ); // $ExpectType (v: number) => (v: number) => number - curryRight( cxt.multiply, 2, { 'count': 2 } ); // $ExpectType (v: number) => (v: number) => number -} - -// The compiler throws an error if the function is provided a first argument other than a function... -{ - curryRight( true ); // $ExpectError - curryRight( false ); // $ExpectError - curryRight( 5 ); // $ExpectError - curryRight( [] ); // $ExpectError - curryRight( {} ); // $ExpectError - curryRight( 'abc' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a this argument which does not constitute a valid `this` context... -{ - const cxt = { - 'count': 0, - 'multiply': function multiply( this: { count: number }, x: number, y: number ): number { - this.count += 1; // eslint-disable-line no-invalid-this - return x * y; - } - }; - curryRight( cxt.multiply, { 'COUNT': 2 } ); // $ExpectError - curryRight( cxt.multiply, 2, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided more than three arguments... -{ - curryRight( ( x: number, y: number ): number => x + y, 2, {}, 4 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 76818ec..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 curryRight = require( './../lib' ); - -var fcn; -var out; -var i; - -function add( x, y, z, w, t, s ) { - return x + y + z + w + t + s; -} - -fcn = curryRight( add ); -out = fcn; -for ( i = 0; i < add.length; i++ ) { - out = out( i*10 ); -} -console.log( out ); 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..7b48901 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function n(n,i,s){var a,u;if(!e(n))throw new TypeError(r("invalid argument. First argument must be a function. Value: `%s`.",n));if(arguments.length<2){if(u=n.length,!t(u))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",u))}else if(arguments.length>2){if(a=s,!t(u=i))throw new TypeError(r("invalid argument. Arity argument must be a positive integer. Value: `%s`.",u))}else if(t(i))u=i;else{if(u=n.length,!t(u))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",u));a=i}return l([]);function l(e){return function(t){var r=e.slice();if(r.unshift(t),r.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","v","cargs","slice","unshift","apply"],"mappings":";;ySAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,oEAAqEP,IAEnG,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,SAE3H,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,4EAA6EH,SAErG,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,IAEjID,EAAUF,CACV,CACD,OAAOU,EAAe,IAStB,SAASA,EAAeC,GACvB,OASA,SAAkBC,GACjB,IAAIC,EAAQF,EAAKG,QAEjB,GADAD,EAAME,QAASH,GACVC,EAAML,OAASL,EACnB,OAAOO,EAAeG,GAEvB,OAAOd,EAAIiB,MAAOd,EAASW,EAC3B,CACD,CACF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 7e7d2e8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform a function into a sequence of functions each accepting a single argument. -* -* @module @stdlib/utils-curry-right -* -* @example -* var curryRight = require( '@stdlib/utils-curry-right' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ - -// 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 8d7768e..0000000 --- a/lib/main.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); - - -// MAIN // - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* @param {Function} fcn - function to curry -* @param {PositiveInteger} [arity=fcn.length] - number of parameters -* @param {*} [thisArg] - evaluation context -* @throws {TypeError} first argument must be a function -* @throws {TypeError} first argument must be a function having at least one parameter -* @throws {TypeError} `arity` argument must be a positive integer -* @returns {Function} curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -function curryRight( fcn, arity, thisArg ) { - var context; - var len; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); - } - if ( arguments.length < 2 ) { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); - } - } else if ( arguments.length > 2 ) { - len = arity; - context = thisArg; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) ); - } - } else if ( isPositiveInteger( arity ) ) { - len = arity; - } else { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); - } - context = arity; - } - return createCurried( [] ); - - /** - * Returns a curry function. - * - * @private - * @param {Array} args - arguments - * @returns {Function} curry function - */ - function createCurried( args ) { - return curried; - - /** - * Curry function. - * - * @private - * @param {*} v - curried function parameter - * @returns {(Function|*)} partially applied curry function or curried function result - */ - function curried( v ) { - var cargs = args.slice(); - cargs.unshift( v ); - if ( cargs.length < len ) { - return createCurried( cargs ); - } - return fcn.apply( context, cargs ); - } - } -} - - -// EXPORTS // - -module.exports = curryRight; diff --git a/package.json b/package.json index 779c22d..206209e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Transform a function into a sequence of functions each accepting a single argument.", "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/assert-is-positive-integer": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/math-base-ops-add3": "^0.1.0", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/random-base-randu": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.1.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..d4b940d --- /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 3f1273f..0000000 --- a/test/test.js +++ /dev/null @@ -1,285 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var add = require( '@stdlib/math-base-ops-add3' ); -var curryRight = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof curryRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (1 arg)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (2 args; context)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an arity argument which is not a positive integer (3 args)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - 0, - -1, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( add, value, {} ); - }; - } -}); - -tape( 'the function returns a function', function test( t ) { - var fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function curries a function', function test( t) { - var fcn; - var f; - - fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'for each invocation where the invocation number is less than the arity, the curried function returns a new partially applied curry function', function test( t ) { - var sum; - var f0; - var f1; - var f2; - - // Initial curried function has no partially applied arguments... - f0 = curryRight( add ); - - sum = f0( 1 )( 2 )( 3 ); - t.strictEqual( sum, 6, 'returns 6' ); - - sum = f0( 1 )( 3 )( 5 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f0( 10 )( 20 )( 40 ); - t.strictEqual( sum, 70, 'returns 70' ); - - // If arity greater than 1, first invocation returns a curried function with one partially applied argument... - f1 = f0( 2 ); - - sum = f1( 3 )( 4 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f1( 10 )( 20 ); - t.strictEqual( sum, 32, 'returns 32' ); - - sum = f1( -1 )( -2 ); - t.strictEqual( sum, -1, 'returns -1' ); - - // If arity greater than 2, second invocation returns a curried function with two partially applied arguments... - f2 = f1( 3 ); - - sum = f2( 5 ); - t.strictEqual( sum, 10, 'returns 10' ); - - sum = f2( 6 ); - t.strictEqual( sum, 11, 'returns 11' ); - - sum = f2( 10 ); - t.strictEqual( sum, 15, 'returns 15' ); - - // And so on and so forth... - - t.end(); -}); - -tape( 'the function supports specifying a function arity', function test( t ) { - var fcn; - var f; - - function add() { - return arguments[ 0 ] + arguments[ 1 ] + arguments[ 2 ]; - } - - fcn = curryRight( add, 3 ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'the function supports specifying a function context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate( length, units, type, color ) { - return this.style+': '+length+units+' '+type+' '+color; - } - }; - - fcn = curryRight( context.generate, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); - -tape( 'the function supports specifying a function arity and context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate() { - return this.style+': '+arguments[0]+arguments[1]+' '+arguments[2]+' '+arguments[3]; - } - }; - - fcn = curryRight( context.generate, 4, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); From a7c15945695757a94b93e63ed35ab4a2da9b6500 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 04:00:17 +0000 Subject: [PATCH 079/140] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a760519..779c22d 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-function": "^0.1.1", "@stdlib/assert-is-positive-integer": "^0.1.0", - "@stdlib/string-format": "^0.1.1" + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/math-base-ops-add3": "^0.1.0", From b54095fe6fd0af1e6b24b9e83756105813d3ad97 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 10:01:04 +0000 Subject: [PATCH 080/140] Remove files --- index.d.ts | 116 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6298 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 a4e85ef..0000000 --- a/index.d.ts +++ /dev/null @@ -1,116 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Utility type to reverse a tuple type. -*/ -type ReverseTuple> = T extends [infer First, ...infer Rest] ? [...ReverseTuple, First] : []; // eslint-disable-line @typescript-eslint/no-explicit-any - -/** - * Curry function type for curryRight. - */ -type CurryRightFunction< - TThis, - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn -> = ( this: TThis, ...args: TArgs ) => TReturn; - -/** -* Curry function. -* -* @param v - curried function parameter -* @returns partially applied curry function or curried function result -*/ -type Closure< - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn -> = ReverseTuple extends [infer TFirst, ...infer TRest] - ? ( v: TFirst ) => Closure, TReturn> - : TReturn; - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param arity - number of parameters -* @param thisArg - evaluation context -* @throws `arity` must be a positive integer -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight< - TThis extends object, - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn ->( - fcn: CurryRightFunction, - arity: number, - thisArg?: TThis -): Closure; - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param thisArg - evaluation context -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight< - TThis extends object, - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn ->( - fcn: CurryRightFunction, - thisArg?: TThis -): Closure; - - -// EXPORTS // - -export = curryRight; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 7b48901..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function n(n,i,s){var a,u;if(!e(n))throw new TypeError(r("invalid argument. First argument must be a function. Value: `%s`.",n));if(arguments.length<2){if(u=n.length,!t(u))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",u))}else if(arguments.length>2){if(a=s,!t(u=i))throw new TypeError(r("invalid argument. Arity argument must be a positive integer. Value: `%s`.",u))}else if(t(i))u=i;else{if(u=n.length,!t(u))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",u));a=i}return l([]);function l(e){return function(t){var r=e.slice();if(r.unshift(t),r.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","v","cargs","slice","unshift","apply"],"mappings":";;ySAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,oEAAqEP,IAEnG,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,SAE3H,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,4EAA6EH,SAErG,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,IAEjID,EAAUF,CACV,CACD,OAAOU,EAAe,IAStB,SAASA,EAAeC,GACvB,OASA,SAAkBC,GACjB,IAAIC,EAAQF,EAAKG,QAEjB,GADAD,EAAME,QAASH,GACVC,EAAML,OAASL,EACnB,OAAOO,EAAeG,GAEvB,OAAOd,EAAIiB,MAAOd,EAASW,EAC3B,CACD,CACF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index d4b940d..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 1337be0f6fa666779968c62ac160c08b2b174aea Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 10:01:22 +0000 Subject: [PATCH 081/140] 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 | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 90 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 53 - docs/types/test.ts | 71 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 110 - package.json | 56 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 285 - 43 files changed, 6200 insertions(+), 4038 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 6ab9858..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-01-01T02:26:20.492Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2b7fad0..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/curry-right) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 9ffcfa1..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/curry-right) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 4887107..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: '6 18 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index e1e3539..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -258,7 +251,7 @@ console.log( out ); ## 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]. @@ -320,11 +313,11 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry +[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry/tree/esm -[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry +[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry/tree/esm -[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right +[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right/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 69ca868..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isFunction = require( '@stdlib/assert-is-function' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var curryRight = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = curryRight( pow ); - if ( typeof out !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( out ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::returned_function', function benchmark( b ) { - var fcn; - var out; - var i; - - fcn = curryRight( pow ); - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = fcn( randu() )( randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::direct', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = pow( randu(), randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 1f7cde2..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/curry-right" -%% click B href "https://github.com/stdlib-js/utils-curry-right/tree/main" -%% click C href "https://github.com/stdlib-js/utils-curry-right/tree/production" -%% click D href "https://github.com/stdlib-js/utils-curry-right/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-curry-right/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-curry-right/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/curry-right -[production-url]: https://github.com/stdlib-js/utils-curry-right/tree/production -[deno-url]: https://github.com/stdlib-js/utils-curry-right/tree/deno -[umd-url]: https://github.com/stdlib-js/utils-curry-right/tree/umd -[esm-url]: https://github.com/stdlib-js/utils-curry-right/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 8166962..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import curryRight from '../docs/types/index'; -export = curryRight; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 16477e0..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var g=f(function(b,o){ -var c=require('@stdlib/assert-is-function/dist'),n=require('@stdlib/assert-is-positive-integer/dist').isPrimitive,a=require('@stdlib/error-tools-fmtprodmsg/dist');function p(t,r,l){var u,e;if(!c(t))throw new TypeError(a('1SN3c',t));if(arguments.length<2){if(e=t.length,!n(e))throw new TypeError(a('1SNEX',e))}else if(arguments.length>2){if(e=r,u=l,!n(e))throw new TypeError(a('1SNAz',e))}else if(n(r))e=r;else{if(e=t.length,!n(e))throw new TypeError(a('1SNEX',e));u=r}return s([]);function s(m){return v;function v(h){var i=m.slice();return i.unshift(h),i.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = curryRight;\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* Transform a function into a sequence of functions each accepting a single argument.\n*\n* @module @stdlib/utils-curry-right\n*\n* @example\n* var curryRight = require( '@stdlib/utils-curry-right' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var f = curryRight( add );\n*\n* var sum = f( 2 )( 3 );\n* // returns 5\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,EAAoB,QAAS,oCAAqC,EAAE,YACpEC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,EAAYC,EAAKC,EAAOC,EAAU,CAC1C,IAAIC,EACAC,EACJ,GAAK,CAACR,EAAYI,CAAI,EACrB,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAI,CAAE,EAEzG,GAAK,UAAU,OAAS,GAEvB,GADAI,EAAMJ,EAAI,OACL,CAACH,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,kGAAmGM,CAAI,CAAE,UAE5H,UAAU,OAAS,GAG9B,GAFAA,EAAMH,EACNE,EAAUD,EACL,CAACL,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,4EAA6EM,CAAI,CAAE,UAEtGP,EAAmBI,CAAM,EACpCG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAI,OACL,CAACH,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,kGAAmGM,CAAI,CAAE,EAEvID,EAAUF,CACX,CACA,OAAOI,EAAe,CAAC,CAAE,EASzB,SAASA,EAAeC,EAAO,CAC9B,OAAOC,EASP,SAASA,EAASC,EAAI,CACrB,IAAIC,EAAQH,EAAK,MAAM,EAEvB,OADAG,EAAM,QAASD,CAAE,EACZC,EAAM,OAASL,EACZC,EAAeI,CAAM,EAEtBT,EAAI,MAAOG,EAASM,CAAM,CAClC,CACD,CACD,CAKAd,EAAO,QAAUI,ICrEjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isPositiveInteger", "format", "curryRight", "fcn", "arity", "thisArg", "context", "len", "createCurried", "args", "curried", "v", "cargs", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7271aed..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,53 +0,0 @@ - -{{alias}}( fcn[, arity][, thisArg] ) - Transforms a function into a sequence of functions each accepting a single - argument. - - Until return value resolution, each invocation returns a new partially - applied curry function. - - This function applies arguments starting from the right. - - Parameters - ---------- - fcn: Function - Function to curry. - - arity: integer (optional) - Number of parameters. Default: `fcn.length`. - - thisArg: any (optional) - Evaluation context. - - Returns - ------- - out: Function - Curry function. - - Examples - -------- - > function add( x, y ) { return x + y; }; - > var f = {{alias}}( add ); - > var sum = f( 2 )( 3 ) - 5 - - // Supply arity: - > function add() { return arguments[ 0 ] + arguments[ 1 ]; }; - > f = {{alias}}( add, 2 ); - > sum = f( 2 )( 3 ) - 5 - - // Provide function context: - > var obj = { - ... 'name': 'Ada', - ... 'greet': function greet( word1, word2 ) { - ... return word1 + ' ' + word2 + ', ' + this.name + '!' - ... } - ... }; - > f = {{alias}}( obj.greet, obj ); - > var str = f( 'there' )( 'Hello' ) - 'Hello there, Ada!' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4577cdb..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,71 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import curryRight = require( './index' ); - - -// TESTS // - -// The function returns a function... -{ - curryRight( ( x: number, y: number ): number => x + y ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: number, y: number ): number => x + y, 2 ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: number, y: number ): number => x + y, 2, {} ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: string, y: string ): string => x + y, {} ); // $ExpectType (v: string) => (v: string) => string - curryRight( ( x: string, y: string ): string => x + y, 2, {} ); // $ExpectType (v: string) => (v: string) => string - curryRight( ( str: string, n: number ): string => str.substring( n ) ); // $ExpectType (v: number) => (v: string) => string - - const cxt = { - 'count': 0, - 'multiply': function multiply( this: { count: number }, x: number, y: number ): number { - this.count += 1; // eslint-disable-line no-invalid-this - return x * y; - } - }; - curryRight( cxt.multiply ); // $ExpectType (v: number) => (v: number) => number - curryRight( cxt.multiply, 2 ); // $ExpectType (v: number) => (v: number) => number - curryRight( cxt.multiply, 2, { 'count': 2 } ); // $ExpectType (v: number) => (v: number) => number -} - -// The compiler throws an error if the function is provided a first argument other than a function... -{ - curryRight( true ); // $ExpectError - curryRight( false ); // $ExpectError - curryRight( 5 ); // $ExpectError - curryRight( [] ); // $ExpectError - curryRight( {} ); // $ExpectError - curryRight( 'abc' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a this argument which does not constitute a valid `this` context... -{ - const cxt = { - 'count': 0, - 'multiply': function multiply( this: { count: number }, x: number, y: number ): number { - this.count += 1; // eslint-disable-line no-invalid-this - return x * y; - } - }; - curryRight( cxt.multiply, { 'COUNT': 2 } ); // $ExpectError - curryRight( cxt.multiply, 2, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided more than three arguments... -{ - curryRight( ( x: number, y: number ): number => x + y, 2, {}, 4 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 76818ec..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 curryRight = require( './../lib' ); - -var fcn; -var out; -var i; - -function add( x, y, z, w, t, s ) { - return x + y + z + w + t + s; -} - -fcn = curryRight( add ); -out = fcn; -for ( i = 0; i < add.length; i++ ) { - out = out( i*10 ); -} -console.log( out ); 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..97f24a2 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function n(n,i,s){var a,u;if(!e(n))throw new TypeError(r("invalid argument. First argument must be a function. Value: `%s`.",n));if(arguments.length<2){if(u=n.length,!t(u))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",u))}else if(arguments.length>2){if(a=s,!t(u=i))throw new TypeError(r("invalid argument. Arity argument must be a positive integer. Value: `%s`.",u))}else if(t(i))u=i;else{if(u=n.length,!t(u))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",u));a=i}return l([]);function l(e){return function(t){var r=e.slice();if(r.unshift(t),r.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","v","cargs","slice","unshift","apply"],"mappings":";;ySAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,oEAAqEP,IAEnG,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,SAE3H,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,4EAA6EH,SAErG,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,IAEjID,EAAUF,CACV,CACD,OAAOU,EAAe,IAStB,SAASA,EAAeC,GACvB,OASA,SAAkBC,GACjB,IAAIC,EAAQF,EAAKG,QAEjB,GADAD,EAAME,QAASH,GACVC,EAAML,OAASL,EACnB,OAAOO,EAAeG,GAEvB,OAAOd,EAAIiB,MAAOd,EAASW,EAC3B,CACD,CACF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 7e7d2e8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform a function into a sequence of functions each accepting a single argument. -* -* @module @stdlib/utils-curry-right -* -* @example -* var curryRight = require( '@stdlib/utils-curry-right' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ - -// 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 8d7768e..0000000 --- a/lib/main.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); - - -// MAIN // - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* @param {Function} fcn - function to curry -* @param {PositiveInteger} [arity=fcn.length] - number of parameters -* @param {*} [thisArg] - evaluation context -* @throws {TypeError} first argument must be a function -* @throws {TypeError} first argument must be a function having at least one parameter -* @throws {TypeError} `arity` argument must be a positive integer -* @returns {Function} curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -function curryRight( fcn, arity, thisArg ) { - var context; - var len; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); - } - if ( arguments.length < 2 ) { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); - } - } else if ( arguments.length > 2 ) { - len = arity; - context = thisArg; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) ); - } - } else if ( isPositiveInteger( arity ) ) { - len = arity; - } else { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); - } - context = arity; - } - return createCurried( [] ); - - /** - * Returns a curry function. - * - * @private - * @param {Array} args - arguments - * @returns {Function} curry function - */ - function createCurried( args ) { - return curried; - - /** - * Curry function. - * - * @private - * @param {*} v - curried function parameter - * @returns {(Function|*)} partially applied curry function or curried function result - */ - function curried( v ) { - var cargs = args.slice(); - cargs.unshift( v ); - if ( cargs.length < len ) { - return createCurried( cargs ); - } - return fcn.apply( context, cargs ); - } - } -} - - -// EXPORTS // - -module.exports = curryRight; diff --git a/package.json b/package.json index 779c22d..206209e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Transform a function into a sequence of functions each accepting a single argument.", "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/assert-is-positive-integer": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/math-base-ops-add3": "^0.1.0", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/random-base-randu": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.1.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..8c4d5d0 --- /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 3f1273f..0000000 --- a/test/test.js +++ /dev/null @@ -1,285 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var add = require( '@stdlib/math-base-ops-add3' ); -var curryRight = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof curryRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (1 arg)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (2 args; context)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an arity argument which is not a positive integer (3 args)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - 0, - -1, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( add, value, {} ); - }; - } -}); - -tape( 'the function returns a function', function test( t ) { - var fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function curries a function', function test( t) { - var fcn; - var f; - - fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'for each invocation where the invocation number is less than the arity, the curried function returns a new partially applied curry function', function test( t ) { - var sum; - var f0; - var f1; - var f2; - - // Initial curried function has no partially applied arguments... - f0 = curryRight( add ); - - sum = f0( 1 )( 2 )( 3 ); - t.strictEqual( sum, 6, 'returns 6' ); - - sum = f0( 1 )( 3 )( 5 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f0( 10 )( 20 )( 40 ); - t.strictEqual( sum, 70, 'returns 70' ); - - // If arity greater than 1, first invocation returns a curried function with one partially applied argument... - f1 = f0( 2 ); - - sum = f1( 3 )( 4 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f1( 10 )( 20 ); - t.strictEqual( sum, 32, 'returns 32' ); - - sum = f1( -1 )( -2 ); - t.strictEqual( sum, -1, 'returns -1' ); - - // If arity greater than 2, second invocation returns a curried function with two partially applied arguments... - f2 = f1( 3 ); - - sum = f2( 5 ); - t.strictEqual( sum, 10, 'returns 10' ); - - sum = f2( 6 ); - t.strictEqual( sum, 11, 'returns 11' ); - - sum = f2( 10 ); - t.strictEqual( sum, 15, 'returns 15' ); - - // And so on and so forth... - - t.end(); -}); - -tape( 'the function supports specifying a function arity', function test( t ) { - var fcn; - var f; - - function add() { - return arguments[ 0 ] + arguments[ 1 ] + arguments[ 2 ]; - } - - fcn = curryRight( add, 3 ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'the function supports specifying a function context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate( length, units, type, color ) { - return this.style+': '+length+units+' '+type+' '+color; - } - }; - - fcn = curryRight( context.generate, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); - -tape( 'the function supports specifying a function arity and context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate() { - return this.style+': '+arguments[0]+arguments[1]+' '+arguments[2]+' '+arguments[3]; - } - }; - - fcn = curryRight( context.generate, 4, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); From c2df792543ed3d10f47aa39da1f2db354387a71a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 04:19:31 +0000 Subject: [PATCH 082/140] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a760519..779c22d 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-function": "^0.1.1", "@stdlib/assert-is-positive-integer": "^0.1.0", - "@stdlib/string-format": "^0.1.1" + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/math-base-ops-add3": "^0.1.0", From f0dfa43b75b73eaf3f1bcab22c8938da7f7e5277 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 09:05:59 +0000 Subject: [PATCH 083/140] Remove files --- index.d.ts | 116 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6298 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 a4e85ef..0000000 --- a/index.d.ts +++ /dev/null @@ -1,116 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Utility type to reverse a tuple type. -*/ -type ReverseTuple> = T extends [infer First, ...infer Rest] ? [...ReverseTuple, First] : []; // eslint-disable-line @typescript-eslint/no-explicit-any - -/** - * Curry function type for curryRight. - */ -type CurryRightFunction< - TThis, - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn -> = ( this: TThis, ...args: TArgs ) => TReturn; - -/** -* Curry function. -* -* @param v - curried function parameter -* @returns partially applied curry function or curried function result -*/ -type Closure< - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn -> = ReverseTuple extends [infer TFirst, ...infer TRest] - ? ( v: TFirst ) => Closure, TReturn> - : TReturn; - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param arity - number of parameters -* @param thisArg - evaluation context -* @throws `arity` must be a positive integer -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight< - TThis extends object, - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn ->( - fcn: CurryRightFunction, - arity: number, - thisArg?: TThis -): Closure; - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param thisArg - evaluation context -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight< - TThis extends object, - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn ->( - fcn: CurryRightFunction, - thisArg?: TThis -): Closure; - - -// EXPORTS // - -export = curryRight; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 97f24a2..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function n(n,i,s){var a,u;if(!e(n))throw new TypeError(r("invalid argument. First argument must be a function. Value: `%s`.",n));if(arguments.length<2){if(u=n.length,!t(u))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",u))}else if(arguments.length>2){if(a=s,!t(u=i))throw new TypeError(r("invalid argument. Arity argument must be a positive integer. Value: `%s`.",u))}else if(t(i))u=i;else{if(u=n.length,!t(u))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",u));a=i}return l([]);function l(e){return function(t){var r=e.slice();if(r.unshift(t),r.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","v","cargs","slice","unshift","apply"],"mappings":";;ySAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,oEAAqEP,IAEnG,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,SAE3H,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,4EAA6EH,SAErG,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,IAEjID,EAAUF,CACV,CACD,OAAOU,EAAe,IAStB,SAASA,EAAeC,GACvB,OASA,SAAkBC,GACjB,IAAIC,EAAQF,EAAKG,QAEjB,GADAD,EAAME,QAASH,GACVC,EAAML,OAASL,EACnB,OAAOO,EAAeG,GAEvB,OAAOd,EAAIiB,MAAOd,EAASW,EAC3B,CACD,CACF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 8c4d5d0..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From de76b937b9e141062dff7ea297c9c726fa928b76 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 09:06:15 +0000 Subject: [PATCH 084/140] 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 | 41 +- SECURITY.md | 5 - benchmark/benchmark.js | 90 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 53 - docs/types/test.ts | 71 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 110 - package.json | 56 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 285 - 43 files changed, 6200 insertions(+), 4043 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 4ded69b..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-02-01T02:55:16.465Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2b7fad0..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/curry-right) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 9ffcfa1..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/curry-right) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 4887107..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: '6 18 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index e1e3539..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -260,7 +251,7 @@ console.log( out ); ## 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]. @@ -325,11 +316,11 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry +[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry/tree/esm -[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry +[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry/tree/esm -[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right +[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right/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 69ca868..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isFunction = require( '@stdlib/assert-is-function' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var curryRight = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = curryRight( pow ); - if ( typeof out !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( out ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::returned_function', function benchmark( b ) { - var fcn; - var out; - var i; - - fcn = curryRight( pow ); - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = fcn( randu() )( randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::direct', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = pow( randu(), randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 7ef3db2..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/curry-right" -%% click B href "https://github.com/stdlib-js/utils-curry-right/tree/main" -%% click C href "https://github.com/stdlib-js/utils-curry-right/tree/production" -%% click D href "https://github.com/stdlib-js/utils-curry-right/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-curry-right/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-curry-right/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/curry-right -[production-url]: https://github.com/stdlib-js/utils-curry-right/tree/production -[deno-url]: https://github.com/stdlib-js/utils-curry-right/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-curry-right/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-curry-right/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-curry-right/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-curry-right/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-curry-right/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 8166962..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import curryRight from '../docs/types/index'; -export = curryRight; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 16477e0..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var g=f(function(b,o){ -var c=require('@stdlib/assert-is-function/dist'),n=require('@stdlib/assert-is-positive-integer/dist').isPrimitive,a=require('@stdlib/error-tools-fmtprodmsg/dist');function p(t,r,l){var u,e;if(!c(t))throw new TypeError(a('1SN3c',t));if(arguments.length<2){if(e=t.length,!n(e))throw new TypeError(a('1SNEX',e))}else if(arguments.length>2){if(e=r,u=l,!n(e))throw new TypeError(a('1SNAz',e))}else if(n(r))e=r;else{if(e=t.length,!n(e))throw new TypeError(a('1SNEX',e));u=r}return s([]);function s(m){return v;function v(h){var i=m.slice();return i.unshift(h),i.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = curryRight;\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* Transform a function into a sequence of functions each accepting a single argument.\n*\n* @module @stdlib/utils-curry-right\n*\n* @example\n* var curryRight = require( '@stdlib/utils-curry-right' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var f = curryRight( add );\n*\n* var sum = f( 2 )( 3 );\n* // returns 5\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,EAAoB,QAAS,oCAAqC,EAAE,YACpEC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,EAAYC,EAAKC,EAAOC,EAAU,CAC1C,IAAIC,EACAC,EACJ,GAAK,CAACR,EAAYI,CAAI,EACrB,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAI,CAAE,EAEzG,GAAK,UAAU,OAAS,GAEvB,GADAI,EAAMJ,EAAI,OACL,CAACH,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,kGAAmGM,CAAI,CAAE,UAE5H,UAAU,OAAS,GAG9B,GAFAA,EAAMH,EACNE,EAAUD,EACL,CAACL,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,4EAA6EM,CAAI,CAAE,UAEtGP,EAAmBI,CAAM,EACpCG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAI,OACL,CAACH,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,kGAAmGM,CAAI,CAAE,EAEvID,EAAUF,CACX,CACA,OAAOI,EAAe,CAAC,CAAE,EASzB,SAASA,EAAeC,EAAO,CAC9B,OAAOC,EASP,SAASA,EAASC,EAAI,CACrB,IAAIC,EAAQH,EAAK,MAAM,EAEvB,OADAG,EAAM,QAASD,CAAE,EACZC,EAAM,OAASL,EACZC,EAAeI,CAAM,EAEtBT,EAAI,MAAOG,EAASM,CAAM,CAClC,CACD,CACD,CAKAd,EAAO,QAAUI,ICrEjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isPositiveInteger", "format", "curryRight", "fcn", "arity", "thisArg", "context", "len", "createCurried", "args", "curried", "v", "cargs", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7271aed..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,53 +0,0 @@ - -{{alias}}( fcn[, arity][, thisArg] ) - Transforms a function into a sequence of functions each accepting a single - argument. - - Until return value resolution, each invocation returns a new partially - applied curry function. - - This function applies arguments starting from the right. - - Parameters - ---------- - fcn: Function - Function to curry. - - arity: integer (optional) - Number of parameters. Default: `fcn.length`. - - thisArg: any (optional) - Evaluation context. - - Returns - ------- - out: Function - Curry function. - - Examples - -------- - > function add( x, y ) { return x + y; }; - > var f = {{alias}}( add ); - > var sum = f( 2 )( 3 ) - 5 - - // Supply arity: - > function add() { return arguments[ 0 ] + arguments[ 1 ]; }; - > f = {{alias}}( add, 2 ); - > sum = f( 2 )( 3 ) - 5 - - // Provide function context: - > var obj = { - ... 'name': 'Ada', - ... 'greet': function greet( word1, word2 ) { - ... return word1 + ' ' + word2 + ', ' + this.name + '!' - ... } - ... }; - > f = {{alias}}( obj.greet, obj ); - > var str = f( 'there' )( 'Hello' ) - 'Hello there, Ada!' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4577cdb..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,71 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import curryRight = require( './index' ); - - -// TESTS // - -// The function returns a function... -{ - curryRight( ( x: number, y: number ): number => x + y ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: number, y: number ): number => x + y, 2 ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: number, y: number ): number => x + y, 2, {} ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: string, y: string ): string => x + y, {} ); // $ExpectType (v: string) => (v: string) => string - curryRight( ( x: string, y: string ): string => x + y, 2, {} ); // $ExpectType (v: string) => (v: string) => string - curryRight( ( str: string, n: number ): string => str.substring( n ) ); // $ExpectType (v: number) => (v: string) => string - - const cxt = { - 'count': 0, - 'multiply': function multiply( this: { count: number }, x: number, y: number ): number { - this.count += 1; // eslint-disable-line no-invalid-this - return x * y; - } - }; - curryRight( cxt.multiply ); // $ExpectType (v: number) => (v: number) => number - curryRight( cxt.multiply, 2 ); // $ExpectType (v: number) => (v: number) => number - curryRight( cxt.multiply, 2, { 'count': 2 } ); // $ExpectType (v: number) => (v: number) => number -} - -// The compiler throws an error if the function is provided a first argument other than a function... -{ - curryRight( true ); // $ExpectError - curryRight( false ); // $ExpectError - curryRight( 5 ); // $ExpectError - curryRight( [] ); // $ExpectError - curryRight( {} ); // $ExpectError - curryRight( 'abc' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a this argument which does not constitute a valid `this` context... -{ - const cxt = { - 'count': 0, - 'multiply': function multiply( this: { count: number }, x: number, y: number ): number { - this.count += 1; // eslint-disable-line no-invalid-this - return x * y; - } - }; - curryRight( cxt.multiply, { 'COUNT': 2 } ); // $ExpectError - curryRight( cxt.multiply, 2, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided more than three arguments... -{ - curryRight( ( x: number, y: number ): number => x + y, 2, {}, 4 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 76818ec..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 curryRight = require( './../lib' ); - -var fcn; -var out; -var i; - -function add( x, y, z, w, t, s ) { - return x + y + z + w + t + s; -} - -fcn = curryRight( add ); -out = fcn; -for ( i = 0; i < add.length; i++ ) { - out = out( i*10 ); -} -console.log( out ); 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..97f24a2 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function n(n,i,s){var a,u;if(!e(n))throw new TypeError(r("invalid argument. First argument must be a function. Value: `%s`.",n));if(arguments.length<2){if(u=n.length,!t(u))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",u))}else if(arguments.length>2){if(a=s,!t(u=i))throw new TypeError(r("invalid argument. Arity argument must be a positive integer. Value: `%s`.",u))}else if(t(i))u=i;else{if(u=n.length,!t(u))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",u));a=i}return l([]);function l(e){return function(t){var r=e.slice();if(r.unshift(t),r.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","v","cargs","slice","unshift","apply"],"mappings":";;ySAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,oEAAqEP,IAEnG,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,SAE3H,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,4EAA6EH,SAErG,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,IAEjID,EAAUF,CACV,CACD,OAAOU,EAAe,IAStB,SAASA,EAAeC,GACvB,OASA,SAAkBC,GACjB,IAAIC,EAAQF,EAAKG,QAEjB,GADAD,EAAME,QAASH,GACVC,EAAML,OAASL,EACnB,OAAOO,EAAeG,GAEvB,OAAOd,EAAIiB,MAAOd,EAASW,EAC3B,CACD,CACF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 7e7d2e8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform a function into a sequence of functions each accepting a single argument. -* -* @module @stdlib/utils-curry-right -* -* @example -* var curryRight = require( '@stdlib/utils-curry-right' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ - -// 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 8d7768e..0000000 --- a/lib/main.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); - - -// MAIN // - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* @param {Function} fcn - function to curry -* @param {PositiveInteger} [arity=fcn.length] - number of parameters -* @param {*} [thisArg] - evaluation context -* @throws {TypeError} first argument must be a function -* @throws {TypeError} first argument must be a function having at least one parameter -* @throws {TypeError} `arity` argument must be a positive integer -* @returns {Function} curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -function curryRight( fcn, arity, thisArg ) { - var context; - var len; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); - } - if ( arguments.length < 2 ) { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); - } - } else if ( arguments.length > 2 ) { - len = arity; - context = thisArg; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) ); - } - } else if ( isPositiveInteger( arity ) ) { - len = arity; - } else { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); - } - context = arity; - } - return createCurried( [] ); - - /** - * Returns a curry function. - * - * @private - * @param {Array} args - arguments - * @returns {Function} curry function - */ - function createCurried( args ) { - return curried; - - /** - * Curry function. - * - * @private - * @param {*} v - curried function parameter - * @returns {(Function|*)} partially applied curry function or curried function result - */ - function curried( v ) { - var cargs = args.slice(); - cargs.unshift( v ); - if ( cargs.length < len ) { - return createCurried( cargs ); - } - return fcn.apply( context, cargs ); - } - } -} - - -// EXPORTS // - -module.exports = curryRight; diff --git a/package.json b/package.json index 779c22d..206209e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Transform a function into a sequence of functions each accepting a single argument.", "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/assert-is-positive-integer": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/math-base-ops-add3": "^0.1.0", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/random-base-randu": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.1.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..873eb09 --- /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 3f1273f..0000000 --- a/test/test.js +++ /dev/null @@ -1,285 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var add = require( '@stdlib/math-base-ops-add3' ); -var curryRight = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof curryRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (1 arg)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (2 args; context)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an arity argument which is not a positive integer (3 args)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - 0, - -1, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( add, value, {} ); - }; - } -}); - -tape( 'the function returns a function', function test( t ) { - var fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function curries a function', function test( t) { - var fcn; - var f; - - fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'for each invocation where the invocation number is less than the arity, the curried function returns a new partially applied curry function', function test( t ) { - var sum; - var f0; - var f1; - var f2; - - // Initial curried function has no partially applied arguments... - f0 = curryRight( add ); - - sum = f0( 1 )( 2 )( 3 ); - t.strictEqual( sum, 6, 'returns 6' ); - - sum = f0( 1 )( 3 )( 5 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f0( 10 )( 20 )( 40 ); - t.strictEqual( sum, 70, 'returns 70' ); - - // If arity greater than 1, first invocation returns a curried function with one partially applied argument... - f1 = f0( 2 ); - - sum = f1( 3 )( 4 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f1( 10 )( 20 ); - t.strictEqual( sum, 32, 'returns 32' ); - - sum = f1( -1 )( -2 ); - t.strictEqual( sum, -1, 'returns -1' ); - - // If arity greater than 2, second invocation returns a curried function with two partially applied arguments... - f2 = f1( 3 ); - - sum = f2( 5 ); - t.strictEqual( sum, 10, 'returns 10' ); - - sum = f2( 6 ); - t.strictEqual( sum, 11, 'returns 11' ); - - sum = f2( 10 ); - t.strictEqual( sum, 15, 'returns 15' ); - - // And so on and so forth... - - t.end(); -}); - -tape( 'the function supports specifying a function arity', function test( t ) { - var fcn; - var f; - - function add() { - return arguments[ 0 ] + arguments[ 1 ] + arguments[ 2 ]; - } - - fcn = curryRight( add, 3 ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'the function supports specifying a function context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate( length, units, type, color ) { - return this.style+': '+length+units+' '+type+' '+color; - } - }; - - fcn = curryRight( context.generate, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); - -tape( 'the function supports specifying a function arity and context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate() { - return this.style+': '+arguments[0]+arguments[1]+' '+arguments[2]+' '+arguments[3]; - } - }; - - fcn = curryRight( context.generate, 4, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); From 919e0f3de86eb3da17685f014bb2c17304d17837 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 08:04:18 +0000 Subject: [PATCH 085/140] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6099406..bc81f0b 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-function": "^0.2.0", "@stdlib/assert-is-positive-integer": "^0.2.0", - "@stdlib/string-format": "^0.2.0" + "@stdlib/error-tools-fmtprodmsg": "^0.2.0" }, "devDependencies": { "@stdlib/math-base-ops-add3": "^0.1.0", From a04a1978adbe1e7fc7ce7a48233a766782f45d9b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 16:12:44 +0000 Subject: [PATCH 086/140] Remove files --- index.d.ts | 116 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6298 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 a4e85ef..0000000 --- a/index.d.ts +++ /dev/null @@ -1,116 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Utility type to reverse a tuple type. -*/ -type ReverseTuple> = T extends [infer First, ...infer Rest] ? [...ReverseTuple, First] : []; // eslint-disable-line @typescript-eslint/no-explicit-any - -/** - * Curry function type for curryRight. - */ -type CurryRightFunction< - TThis, - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn -> = ( this: TThis, ...args: TArgs ) => TReturn; - -/** -* Curry function. -* -* @param v - curried function parameter -* @returns partially applied curry function or curried function result -*/ -type Closure< - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn -> = ReverseTuple extends [infer TFirst, ...infer TRest] - ? ( v: TFirst ) => Closure, TReturn> - : TReturn; - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param arity - number of parameters -* @param thisArg - evaluation context -* @throws `arity` must be a positive integer -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight< - TThis extends object, - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn ->( - fcn: CurryRightFunction, - arity: number, - thisArg?: TThis -): Closure; - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param thisArg - evaluation context -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight< - TThis extends object, - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn ->( - fcn: CurryRightFunction, - thisArg?: TThis -): Closure; - - -// EXPORTS // - -export = curryRight; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 97f24a2..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.1.1-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function n(n,i,s){var a,u;if(!e(n))throw new TypeError(r("invalid argument. First argument must be a function. Value: `%s`.",n));if(arguments.length<2){if(u=n.length,!t(u))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",u))}else if(arguments.length>2){if(a=s,!t(u=i))throw new TypeError(r("invalid argument. Arity argument must be a positive integer. Value: `%s`.",u))}else if(t(i))u=i;else{if(u=n.length,!t(u))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",u));a=i}return l([]);function l(e){return function(t){var r=e.slice();if(r.unshift(t),r.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","v","cargs","slice","unshift","apply"],"mappings":";;ySAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,oEAAqEP,IAEnG,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,SAE3H,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,4EAA6EH,SAErG,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,IAEjID,EAAUF,CACV,CACD,OAAOU,EAAe,IAStB,SAASA,EAAeC,GACvB,OASA,SAAkBC,GACjB,IAAIC,EAAQF,EAAKG,QAEjB,GADAD,EAAME,QAASH,GACVC,EAAML,OAASL,EACnB,OAAOO,EAAeG,GAEvB,OAAOd,EAAIiB,MAAOd,EAASW,EAC3B,CACD,CACF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 873eb09..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From e6b8c044a67d936aaecdc20c4595fdfc583e800d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 16:13:29 +0000 Subject: [PATCH 087/140] 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 | 41 +- SECURITY.md | 5 - benchmark/benchmark.js | 90 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 53 - docs/types/test.ts | 71 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 110 - package.json | 56 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 285 - 42 files changed, 6200 insertions(+), 4046 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 2b7fad0..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/curry-right) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 9ffcfa1..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/curry-right) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 fd5a915..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: '6 18 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 9106b5d..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -260,7 +251,7 @@ console.log( out ); ## 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]. @@ -325,11 +316,11 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry +[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry/tree/esm -[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry +[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry/tree/esm -[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right +[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right/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 69ca868..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isFunction = require( '@stdlib/assert-is-function' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var curryRight = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = curryRight( pow ); - if ( typeof out !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( out ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::returned_function', function benchmark( b ) { - var fcn; - var out; - var i; - - fcn = curryRight( pow ); - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = fcn( randu() )( randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::direct', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = pow( randu(), randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 7ef3db2..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/curry-right" -%% click B href "https://github.com/stdlib-js/utils-curry-right/tree/main" -%% click C href "https://github.com/stdlib-js/utils-curry-right/tree/production" -%% click D href "https://github.com/stdlib-js/utils-curry-right/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-curry-right/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-curry-right/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/curry-right -[production-url]: https://github.com/stdlib-js/utils-curry-right/tree/production -[deno-url]: https://github.com/stdlib-js/utils-curry-right/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-curry-right/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-curry-right/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-curry-right/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-curry-right/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-curry-right/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 8166962..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import curryRight from '../docs/types/index'; -export = curryRight; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 16477e0..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var g=f(function(b,o){ -var c=require('@stdlib/assert-is-function/dist'),n=require('@stdlib/assert-is-positive-integer/dist').isPrimitive,a=require('@stdlib/error-tools-fmtprodmsg/dist');function p(t,r,l){var u,e;if(!c(t))throw new TypeError(a('1SN3c',t));if(arguments.length<2){if(e=t.length,!n(e))throw new TypeError(a('1SNEX',e))}else if(arguments.length>2){if(e=r,u=l,!n(e))throw new TypeError(a('1SNAz',e))}else if(n(r))e=r;else{if(e=t.length,!n(e))throw new TypeError(a('1SNEX',e));u=r}return s([]);function s(m){return v;function v(h){var i=m.slice();return i.unshift(h),i.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = curryRight;\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* Transform a function into a sequence of functions each accepting a single argument.\n*\n* @module @stdlib/utils-curry-right\n*\n* @example\n* var curryRight = require( '@stdlib/utils-curry-right' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var f = curryRight( add );\n*\n* var sum = f( 2 )( 3 );\n* // returns 5\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,EAAoB,QAAS,oCAAqC,EAAE,YACpEC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,EAAYC,EAAKC,EAAOC,EAAU,CAC1C,IAAIC,EACAC,EACJ,GAAK,CAACR,EAAYI,CAAI,EACrB,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAI,CAAE,EAEzG,GAAK,UAAU,OAAS,GAEvB,GADAI,EAAMJ,EAAI,OACL,CAACH,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,kGAAmGM,CAAI,CAAE,UAE5H,UAAU,OAAS,GAG9B,GAFAA,EAAMH,EACNE,EAAUD,EACL,CAACL,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,4EAA6EM,CAAI,CAAE,UAEtGP,EAAmBI,CAAM,EACpCG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAI,OACL,CAACH,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,kGAAmGM,CAAI,CAAE,EAEvID,EAAUF,CACX,CACA,OAAOI,EAAe,CAAC,CAAE,EASzB,SAASA,EAAeC,EAAO,CAC9B,OAAOC,EASP,SAASA,EAASC,EAAI,CACrB,IAAIC,EAAQH,EAAK,MAAM,EAEvB,OADAG,EAAM,QAASD,CAAE,EACZC,EAAM,OAASL,EACZC,EAAeI,CAAM,EAEtBT,EAAI,MAAOG,EAASM,CAAM,CAClC,CACD,CACD,CAKAd,EAAO,QAAUI,ICrEjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isPositiveInteger", "format", "curryRight", "fcn", "arity", "thisArg", "context", "len", "createCurried", "args", "curried", "v", "cargs", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7271aed..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,53 +0,0 @@ - -{{alias}}( fcn[, arity][, thisArg] ) - Transforms a function into a sequence of functions each accepting a single - argument. - - Until return value resolution, each invocation returns a new partially - applied curry function. - - This function applies arguments starting from the right. - - Parameters - ---------- - fcn: Function - Function to curry. - - arity: integer (optional) - Number of parameters. Default: `fcn.length`. - - thisArg: any (optional) - Evaluation context. - - Returns - ------- - out: Function - Curry function. - - Examples - -------- - > function add( x, y ) { return x + y; }; - > var f = {{alias}}( add ); - > var sum = f( 2 )( 3 ) - 5 - - // Supply arity: - > function add() { return arguments[ 0 ] + arguments[ 1 ]; }; - > f = {{alias}}( add, 2 ); - > sum = f( 2 )( 3 ) - 5 - - // Provide function context: - > var obj = { - ... 'name': 'Ada', - ... 'greet': function greet( word1, word2 ) { - ... return word1 + ' ' + word2 + ', ' + this.name + '!' - ... } - ... }; - > f = {{alias}}( obj.greet, obj ); - > var str = f( 'there' )( 'Hello' ) - 'Hello there, Ada!' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4577cdb..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,71 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import curryRight = require( './index' ); - - -// TESTS // - -// The function returns a function... -{ - curryRight( ( x: number, y: number ): number => x + y ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: number, y: number ): number => x + y, 2 ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: number, y: number ): number => x + y, 2, {} ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: string, y: string ): string => x + y, {} ); // $ExpectType (v: string) => (v: string) => string - curryRight( ( x: string, y: string ): string => x + y, 2, {} ); // $ExpectType (v: string) => (v: string) => string - curryRight( ( str: string, n: number ): string => str.substring( n ) ); // $ExpectType (v: number) => (v: string) => string - - const cxt = { - 'count': 0, - 'multiply': function multiply( this: { count: number }, x: number, y: number ): number { - this.count += 1; // eslint-disable-line no-invalid-this - return x * y; - } - }; - curryRight( cxt.multiply ); // $ExpectType (v: number) => (v: number) => number - curryRight( cxt.multiply, 2 ); // $ExpectType (v: number) => (v: number) => number - curryRight( cxt.multiply, 2, { 'count': 2 } ); // $ExpectType (v: number) => (v: number) => number -} - -// The compiler throws an error if the function is provided a first argument other than a function... -{ - curryRight( true ); // $ExpectError - curryRight( false ); // $ExpectError - curryRight( 5 ); // $ExpectError - curryRight( [] ); // $ExpectError - curryRight( {} ); // $ExpectError - curryRight( 'abc' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a this argument which does not constitute a valid `this` context... -{ - const cxt = { - 'count': 0, - 'multiply': function multiply( this: { count: number }, x: number, y: number ): number { - this.count += 1; // eslint-disable-line no-invalid-this - return x * y; - } - }; - curryRight( cxt.multiply, { 'COUNT': 2 } ); // $ExpectError - curryRight( cxt.multiply, 2, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided more than three arguments... -{ - curryRight( ( x: number, y: number ): number => x + y, 2, {}, 4 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 76818ec..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 curryRight = require( './../lib' ); - -var fcn; -var out; -var i; - -function add( x, y, z, w, t, s ) { - return x + y + z + w + t + s; -} - -fcn = curryRight( add ); -out = fcn; -for ( i = 0; i < add.length; i++ ) { - out = out( i*10 ); -} -console.log( out ); 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..a4b6b58 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.0-esm/index.mjs";import{isPrimitive as t}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function n(n,i,s){var a,u;if(!e(n))throw new TypeError(r("invalid argument. First argument must be a function. Value: `%s`.",n));if(arguments.length<2){if(u=n.length,!t(u))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",u))}else if(arguments.length>2){if(a=s,!t(u=i))throw new TypeError(r("invalid argument. Arity argument must be a positive integer. Value: `%s`.",u))}else if(t(i))u=i;else{if(u=n.length,!t(u))throw new TypeError(r("invalid argument. First argument must be a function having at least one parameter. Value: `%s`.",u));a=i}return l([]);function l(e){return function(t){var r=e.slice();if(r.unshift(t),r.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","v","cargs","slice","unshift","apply"],"mappings":";;ySAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,oEAAqEP,IAEnG,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,SAE3H,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,4EAA6EH,SAErG,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,kGAAmGH,IAEjID,EAAUF,CACV,CACD,OAAOU,EAAe,IAStB,SAASA,EAAeC,GACvB,OASA,SAAkBC,GACjB,IAAIC,EAAQF,EAAKG,QAEjB,GADAD,EAAME,QAASH,GACVC,EAAML,OAASL,EACnB,OAAOO,EAAeG,GAEvB,OAAOd,EAAIiB,MAAOd,EAASW,EAC3B,CACD,CACF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 7e7d2e8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform a function into a sequence of functions each accepting a single argument. -* -* @module @stdlib/utils-curry-right -* -* @example -* var curryRight = require( '@stdlib/utils-curry-right' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ - -// 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 8d7768e..0000000 --- a/lib/main.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); - - -// MAIN // - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* @param {Function} fcn - function to curry -* @param {PositiveInteger} [arity=fcn.length] - number of parameters -* @param {*} [thisArg] - evaluation context -* @throws {TypeError} first argument must be a function -* @throws {TypeError} first argument must be a function having at least one parameter -* @throws {TypeError} `arity` argument must be a positive integer -* @returns {Function} curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -function curryRight( fcn, arity, thisArg ) { - var context; - var len; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); - } - if ( arguments.length < 2 ) { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); - } - } else if ( arguments.length > 2 ) { - len = arity; - context = thisArg; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) ); - } - } else if ( isPositiveInteger( arity ) ) { - len = arity; - } else { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); - } - context = arity; - } - return createCurried( [] ); - - /** - * Returns a curry function. - * - * @private - * @param {Array} args - arguments - * @returns {Function} curry function - */ - function createCurried( args ) { - return curried; - - /** - * Curry function. - * - * @private - * @param {*} v - curried function parameter - * @returns {(Function|*)} partially applied curry function or curried function result - */ - function curried( v ) { - var cargs = args.slice(); - cargs.unshift( v ); - if ( cargs.length < len ) { - return createCurried( cargs ); - } - return fcn.apply( context, cargs ); - } - } -} - - -// EXPORTS // - -module.exports = curryRight; diff --git a/package.json b/package.json index bc81f0b..2c88c1d 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.0", "description": "Transform a function into a sequence of functions each accepting a single argument.", "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/assert-is-positive-integer": "^0.2.0", - "@stdlib/error-tools-fmtprodmsg": "^0.2.0" - }, - "devDependencies": { - "@stdlib/math-base-ops-add3": "^0.1.0", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/random-base-randu": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.1.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..4a8d863 --- /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 3f1273f..0000000 --- a/test/test.js +++ /dev/null @@ -1,285 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var add = require( '@stdlib/math-base-ops-add3' ); -var curryRight = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof curryRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (1 arg)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (2 args; context)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an arity argument which is not a positive integer (3 args)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - 0, - -1, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( add, value, {} ); - }; - } -}); - -tape( 'the function returns a function', function test( t ) { - var fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function curries a function', function test( t) { - var fcn; - var f; - - fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'for each invocation where the invocation number is less than the arity, the curried function returns a new partially applied curry function', function test( t ) { - var sum; - var f0; - var f1; - var f2; - - // Initial curried function has no partially applied arguments... - f0 = curryRight( add ); - - sum = f0( 1 )( 2 )( 3 ); - t.strictEqual( sum, 6, 'returns 6' ); - - sum = f0( 1 )( 3 )( 5 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f0( 10 )( 20 )( 40 ); - t.strictEqual( sum, 70, 'returns 70' ); - - // If arity greater than 1, first invocation returns a curried function with one partially applied argument... - f1 = f0( 2 ); - - sum = f1( 3 )( 4 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f1( 10 )( 20 ); - t.strictEqual( sum, 32, 'returns 32' ); - - sum = f1( -1 )( -2 ); - t.strictEqual( sum, -1, 'returns -1' ); - - // If arity greater than 2, second invocation returns a curried function with two partially applied arguments... - f2 = f1( 3 ); - - sum = f2( 5 ); - t.strictEqual( sum, 10, 'returns 10' ); - - sum = f2( 6 ); - t.strictEqual( sum, 11, 'returns 11' ); - - sum = f2( 10 ); - t.strictEqual( sum, 15, 'returns 15' ); - - // And so on and so forth... - - t.end(); -}); - -tape( 'the function supports specifying a function arity', function test( t ) { - var fcn; - var f; - - function add() { - return arguments[ 0 ] + arguments[ 1 ] + arguments[ 2 ]; - } - - fcn = curryRight( add, 3 ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'the function supports specifying a function context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate( length, units, type, color ) { - return this.style+': '+length+units+' '+type+' '+color; - } - }; - - fcn = curryRight( context.generate, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); - -tape( 'the function supports specifying a function arity and context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate() { - return this.style+': '+arguments[0]+arguments[1]+' '+arguments[2]+' '+arguments[3]; - } - }; - - fcn = curryRight( context.generate, 4, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); From 744fd81dd10c77ab7ea6c942630d38b5f202c331 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 19:29:04 +0000 Subject: [PATCH 088/140] 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 9916bb2..884297d 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import curryRight from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-curry-right@esm/index.mjs'; +import curryRight from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-curry-right@v0.2.0-esm/index.mjs'; ``` #### curryRight( fcn\[, arity]\[, thisArg] ) @@ -192,7 +192,7 @@ var str = fcn( 'there' )( 'Hello' ); - - - - From ed2de3501a85058cfda8f2e8b0e627138b97d6c1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 24 Feb 2024 16:17:20 +0000 Subject: [PATCH 092/140] 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 | 41 +- SECURITY.md | 5 - benchmark/benchmark.js | 90 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 53 - docs/types/test.ts | 71 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 110 - package.json | 56 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 285 -- 42 files changed, 4865 insertions(+), 4040 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 2b7fad0..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/curry-right) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 9ffcfa1..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/curry-right) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 906f5af..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: '6 18 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 9106b5d..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -260,7 +251,7 @@ console.log( out ); ## 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]. @@ -325,11 +316,11 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry +[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry/tree/esm -[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry +[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry/tree/esm -[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right +[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right/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 69ca868..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isFunction = require( '@stdlib/assert-is-function' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var curryRight = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = curryRight( pow ); - if ( typeof out !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( out ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::returned_function', function benchmark( b ) { - var fcn; - var out; - var i; - - fcn = curryRight( pow ); - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = fcn( randu() )( randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::direct', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = pow( randu(), randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 7ef3db2..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/curry-right" -%% click B href "https://github.com/stdlib-js/utils-curry-right/tree/main" -%% click C href "https://github.com/stdlib-js/utils-curry-right/tree/production" -%% click D href "https://github.com/stdlib-js/utils-curry-right/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-curry-right/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-curry-right/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/curry-right -[production-url]: https://github.com/stdlib-js/utils-curry-right/tree/production -[deno-url]: https://github.com/stdlib-js/utils-curry-right/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-curry-right/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-curry-right/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-curry-right/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-curry-right/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-curry-right/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 8166962..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import curryRight from '../docs/types/index'; -export = curryRight; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 16477e0..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var g=f(function(b,o){ -var c=require('@stdlib/assert-is-function/dist'),n=require('@stdlib/assert-is-positive-integer/dist').isPrimitive,a=require('@stdlib/error-tools-fmtprodmsg/dist');function p(t,r,l){var u,e;if(!c(t))throw new TypeError(a('1SN3c',t));if(arguments.length<2){if(e=t.length,!n(e))throw new TypeError(a('1SNEX',e))}else if(arguments.length>2){if(e=r,u=l,!n(e))throw new TypeError(a('1SNAz',e))}else if(n(r))e=r;else{if(e=t.length,!n(e))throw new TypeError(a('1SNEX',e));u=r}return s([]);function s(m){return v;function v(h){var i=m.slice();return i.unshift(h),i.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = curryRight;\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* Transform a function into a sequence of functions each accepting a single argument.\n*\n* @module @stdlib/utils-curry-right\n*\n* @example\n* var curryRight = require( '@stdlib/utils-curry-right' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var f = curryRight( add );\n*\n* var sum = f( 2 )( 3 );\n* // returns 5\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,EAAoB,QAAS,oCAAqC,EAAE,YACpEC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,EAAYC,EAAKC,EAAOC,EAAU,CAC1C,IAAIC,EACAC,EACJ,GAAK,CAACR,EAAYI,CAAI,EACrB,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAI,CAAE,EAEzG,GAAK,UAAU,OAAS,GAEvB,GADAI,EAAMJ,EAAI,OACL,CAACH,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,kGAAmGM,CAAI,CAAE,UAE5H,UAAU,OAAS,GAG9B,GAFAA,EAAMH,EACNE,EAAUD,EACL,CAACL,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,4EAA6EM,CAAI,CAAE,UAEtGP,EAAmBI,CAAM,EACpCG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAI,OACL,CAACH,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,kGAAmGM,CAAI,CAAE,EAEvID,EAAUF,CACX,CACA,OAAOI,EAAe,CAAC,CAAE,EASzB,SAASA,EAAeC,EAAO,CAC9B,OAAOC,EASP,SAASA,EAASC,EAAI,CACrB,IAAIC,EAAQH,EAAK,MAAM,EAEvB,OADAG,EAAM,QAASD,CAAE,EACZC,EAAM,OAASL,EACZC,EAAeI,CAAM,EAEtBT,EAAI,MAAOG,EAASM,CAAM,CAClC,CACD,CACD,CAKAd,EAAO,QAAUI,ICrEjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isPositiveInteger", "format", "curryRight", "fcn", "arity", "thisArg", "context", "len", "createCurried", "args", "curried", "v", "cargs", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7271aed..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,53 +0,0 @@ - -{{alias}}( fcn[, arity][, thisArg] ) - Transforms a function into a sequence of functions each accepting a single - argument. - - Until return value resolution, each invocation returns a new partially - applied curry function. - - This function applies arguments starting from the right. - - Parameters - ---------- - fcn: Function - Function to curry. - - arity: integer (optional) - Number of parameters. Default: `fcn.length`. - - thisArg: any (optional) - Evaluation context. - - Returns - ------- - out: Function - Curry function. - - Examples - -------- - > function add( x, y ) { return x + y; }; - > var f = {{alias}}( add ); - > var sum = f( 2 )( 3 ) - 5 - - // Supply arity: - > function add() { return arguments[ 0 ] + arguments[ 1 ]; }; - > f = {{alias}}( add, 2 ); - > sum = f( 2 )( 3 ) - 5 - - // Provide function context: - > var obj = { - ... 'name': 'Ada', - ... 'greet': function greet( word1, word2 ) { - ... return word1 + ' ' + word2 + ', ' + this.name + '!' - ... } - ... }; - > f = {{alias}}( obj.greet, obj ); - > var str = f( 'there' )( 'Hello' ) - 'Hello there, Ada!' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4577cdb..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,71 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import curryRight = require( './index' ); - - -// TESTS // - -// The function returns a function... -{ - curryRight( ( x: number, y: number ): number => x + y ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: number, y: number ): number => x + y, 2 ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: number, y: number ): number => x + y, 2, {} ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: string, y: string ): string => x + y, {} ); // $ExpectType (v: string) => (v: string) => string - curryRight( ( x: string, y: string ): string => x + y, 2, {} ); // $ExpectType (v: string) => (v: string) => string - curryRight( ( str: string, n: number ): string => str.substring( n ) ); // $ExpectType (v: number) => (v: string) => string - - const cxt = { - 'count': 0, - 'multiply': function multiply( this: { count: number }, x: number, y: number ): number { - this.count += 1; // eslint-disable-line no-invalid-this - return x * y; - } - }; - curryRight( cxt.multiply ); // $ExpectType (v: number) => (v: number) => number - curryRight( cxt.multiply, 2 ); // $ExpectType (v: number) => (v: number) => number - curryRight( cxt.multiply, 2, { 'count': 2 } ); // $ExpectType (v: number) => (v: number) => number -} - -// The compiler throws an error if the function is provided a first argument other than a function... -{ - curryRight( true ); // $ExpectError - curryRight( false ); // $ExpectError - curryRight( 5 ); // $ExpectError - curryRight( [] ); // $ExpectError - curryRight( {} ); // $ExpectError - curryRight( 'abc' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a this argument which does not constitute a valid `this` context... -{ - const cxt = { - 'count': 0, - 'multiply': function multiply( this: { count: number }, x: number, y: number ): number { - this.count += 1; // eslint-disable-line no-invalid-this - return x * y; - } - }; - curryRight( cxt.multiply, { 'COUNT': 2 } ); // $ExpectError - curryRight( cxt.multiply, 2, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided more than three arguments... -{ - curryRight( ( x: number, y: number ): number => x + y, 2, {}, 4 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 76818ec..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 curryRight = require( './../lib' ); - -var fcn; -var out; -var i; - -function add( x, y, z, w, t, s ) { - return x + y + z + w + t + s; -} - -fcn = curryRight( add ); -out = fcn; -for ( i = 0; i < add.length; i++ ) { - out = out( i*10 ); -} -console.log( out ); 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..ffa78e8 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@v0.2.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function s(s,n,i){var o,l;if(!e(s))throw new TypeError(t("1SN3c",s));if(arguments.length<2){if(l=s.length,!r(l))throw new TypeError(t("1SNEX",l))}else if(arguments.length>2){if(o=i,!r(l=n))throw new TypeError(t("1SNAz",l))}else if(r(n))l=n;else{if(l=s.length,!r(l))throw new TypeError(t("1SNEX",l));o=n}return function e(r){return t;function t(t){var n=r.slice();return n.unshift(t),n.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNAz', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNEX', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","curried","v","cargs","slice","unshift","apply"],"mappings":";;kTAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,SAEjC,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAEjC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvCD,EAAUF,CACV,CACD,OASA,SAASU,EAAeC,GACvB,OAAOC,EASP,SAASA,EAASC,GACjB,IAAIC,EAAQH,EAAKI,QAEjB,OADAD,EAAME,QAASH,GACVC,EAAMN,OAASL,EACZO,EAAeI,GAEhBf,EAAIkB,MAAOf,EAASY,EAC3B,CACD,CA3BMJ,CAAe,GA4BvB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 7e7d2e8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform a function into a sequence of functions each accepting a single argument. -* -* @module @stdlib/utils-curry-right -* -* @example -* var curryRight = require( '@stdlib/utils-curry-right' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ - -// 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 ffb671a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* @param {Function} fcn - function to curry -* @param {PositiveInteger} [arity=fcn.length] - number of parameters -* @param {*} [thisArg] - evaluation context -* @throws {TypeError} first argument must be a function -* @throws {TypeError} first argument must be a function having at least one parameter -* @throws {TypeError} `arity` argument must be a positive integer -* @returns {Function} curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -function curryRight( fcn, arity, thisArg ) { - var context; - var len; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '1SN3c', fcn ) ); - } - if ( arguments.length < 2 ) { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNEX', len ) ); - } - } else if ( arguments.length > 2 ) { - len = arity; - context = thisArg; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNAz', len ) ); - } - } else if ( isPositiveInteger( arity ) ) { - len = arity; - } else { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNEX', len ) ); - } - context = arity; - } - return createCurried( [] ); - - /** - * Returns a curry function. - * - * @private - * @param {Array} args - arguments - * @returns {Function} curry function - */ - function createCurried( args ) { - return curried; - - /** - * Curry function. - * - * @private - * @param {*} v - curried function parameter - * @returns {(Function|*)} partially applied curry function or curried function result - */ - function curried( v ) { - var cargs = args.slice(); - cargs.unshift( v ); - if ( cargs.length < len ) { - return createCurried( cargs ); - } - return fcn.apply( context, cargs ); - } - } -} - - -// EXPORTS // - -module.exports = curryRight; diff --git a/package.json b/package.json index 71e82a5..be38e0f 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Transform a function into a sequence of functions each accepting a single argument.", "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/assert-is-positive-integer": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/math-base-ops-add3": "^0.2.1", - "@stdlib/math-base-special-pow": "^0.2.0", - "@stdlib/random-base-randu": "^0.2.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.0" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdutils", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..20b8ff0 --- /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 3f1273f..0000000 --- a/test/test.js +++ /dev/null @@ -1,285 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var add = require( '@stdlib/math-base-ops-add3' ); -var curryRight = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof curryRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (1 arg)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (2 args; context)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an arity argument which is not a positive integer (3 args)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - 0, - -1, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( add, value, {} ); - }; - } -}); - -tape( 'the function returns a function', function test( t ) { - var fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function curries a function', function test( t) { - var fcn; - var f; - - fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'for each invocation where the invocation number is less than the arity, the curried function returns a new partially applied curry function', function test( t ) { - var sum; - var f0; - var f1; - var f2; - - // Initial curried function has no partially applied arguments... - f0 = curryRight( add ); - - sum = f0( 1 )( 2 )( 3 ); - t.strictEqual( sum, 6, 'returns 6' ); - - sum = f0( 1 )( 3 )( 5 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f0( 10 )( 20 )( 40 ); - t.strictEqual( sum, 70, 'returns 70' ); - - // If arity greater than 1, first invocation returns a curried function with one partially applied argument... - f1 = f0( 2 ); - - sum = f1( 3 )( 4 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f1( 10 )( 20 ); - t.strictEqual( sum, 32, 'returns 32' ); - - sum = f1( -1 )( -2 ); - t.strictEqual( sum, -1, 'returns -1' ); - - // If arity greater than 2, second invocation returns a curried function with two partially applied arguments... - f2 = f1( 3 ); - - sum = f2( 5 ); - t.strictEqual( sum, 10, 'returns 10' ); - - sum = f2( 6 ); - t.strictEqual( sum, 11, 'returns 11' ); - - sum = f2( 10 ); - t.strictEqual( sum, 15, 'returns 15' ); - - // And so on and so forth... - - t.end(); -}); - -tape( 'the function supports specifying a function arity', function test( t ) { - var fcn; - var f; - - function add() { - return arguments[ 0 ] + arguments[ 1 ] + arguments[ 2 ]; - } - - fcn = curryRight( add, 3 ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'the function supports specifying a function context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate( length, units, type, color ) { - return this.style+': '+length+units+' '+type+' '+color; - } - }; - - fcn = curryRight( context.generate, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); - -tape( 'the function supports specifying a function arity and context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate() { - return this.style+': '+arguments[0]+arguments[1]+' '+arguments[2]+' '+arguments[3]; - } - }; - - fcn = curryRight( context.generate, 4, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); From 75c690b5502d43e7def1ca08de3e16d884bef969 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 24 Feb 2024 17:09:08 +0000 Subject: [PATCH 093/140] 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 4bb0ea7..1b7d84f 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import curryRight from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-curry-right@esm/index.mjs'; +import curryRight from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-curry-right@v0.2.1-esm/index.mjs'; ``` #### curryRight( fcn\[, arity]\[, thisArg] ) @@ -192,7 +192,7 @@ var str = fcn( 'there' )( 'Hello' ); - - - - From 54520203f831d08217d7e164d2b1e22bcd20c103 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 07:36:21 +0000 Subject: [PATCH 097/140] 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 | 41 +- SECURITY.md | 5 - benchmark/benchmark.js | 90 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 53 - docs/types/test.ts | 71 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 110 - package.json | 57 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 285 -- 43 files changed, 4865 insertions(+), 4043 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 8104706..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-03-01T02:50:26.331Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2b7fad0..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/curry-right) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 9ffcfa1..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/curry-right) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 906f5af..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: '6 18 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 9106b5d..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -260,7 +251,7 @@ console.log( out ); ## 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]. @@ -325,11 +316,11 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry +[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry/tree/esm -[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry +[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry/tree/esm -[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right +[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right/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 69ca868..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isFunction = require( '@stdlib/assert-is-function' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var curryRight = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = curryRight( pow ); - if ( typeof out !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( out ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::returned_function', function benchmark( b ) { - var fcn; - var out; - var i; - - fcn = curryRight( pow ); - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = fcn( randu() )( randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::direct', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = pow( randu(), randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 7ef3db2..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/curry-right" -%% click B href "https://github.com/stdlib-js/utils-curry-right/tree/main" -%% click C href "https://github.com/stdlib-js/utils-curry-right/tree/production" -%% click D href "https://github.com/stdlib-js/utils-curry-right/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-curry-right/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-curry-right/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/curry-right -[production-url]: https://github.com/stdlib-js/utils-curry-right/tree/production -[deno-url]: https://github.com/stdlib-js/utils-curry-right/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-curry-right/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-curry-right/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-curry-right/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-curry-right/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-curry-right/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 8166962..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import curryRight from '../docs/types/index'; -export = curryRight; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 16477e0..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var g=f(function(b,o){ -var c=require('@stdlib/assert-is-function/dist'),n=require('@stdlib/assert-is-positive-integer/dist').isPrimitive,a=require('@stdlib/error-tools-fmtprodmsg/dist');function p(t,r,l){var u,e;if(!c(t))throw new TypeError(a('1SN3c',t));if(arguments.length<2){if(e=t.length,!n(e))throw new TypeError(a('1SNEX',e))}else if(arguments.length>2){if(e=r,u=l,!n(e))throw new TypeError(a('1SNAz',e))}else if(n(r))e=r;else{if(e=t.length,!n(e))throw new TypeError(a('1SNEX',e));u=r}return s([]);function s(m){return v;function v(h){var i=m.slice();return i.unshift(h),i.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = curryRight;\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* Transform a function into a sequence of functions each accepting a single argument.\n*\n* @module @stdlib/utils-curry-right\n*\n* @example\n* var curryRight = require( '@stdlib/utils-curry-right' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var f = curryRight( add );\n*\n* var sum = f( 2 )( 3 );\n* // returns 5\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,EAAoB,QAAS,oCAAqC,EAAE,YACpEC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,EAAYC,EAAKC,EAAOC,EAAU,CAC1C,IAAIC,EACAC,EACJ,GAAK,CAACR,EAAYI,CAAI,EACrB,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAI,CAAE,EAEzG,GAAK,UAAU,OAAS,GAEvB,GADAI,EAAMJ,EAAI,OACL,CAACH,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,kGAAmGM,CAAI,CAAE,UAE5H,UAAU,OAAS,GAG9B,GAFAA,EAAMH,EACNE,EAAUD,EACL,CAACL,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,4EAA6EM,CAAI,CAAE,UAEtGP,EAAmBI,CAAM,EACpCG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAI,OACL,CAACH,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,kGAAmGM,CAAI,CAAE,EAEvID,EAAUF,CACX,CACA,OAAOI,EAAe,CAAC,CAAE,EASzB,SAASA,EAAeC,EAAO,CAC9B,OAAOC,EASP,SAASA,EAASC,EAAI,CACrB,IAAIC,EAAQH,EAAK,MAAM,EAEvB,OADAG,EAAM,QAASD,CAAE,EACZC,EAAM,OAASL,EACZC,EAAeI,CAAM,EAEtBT,EAAI,MAAOG,EAASM,CAAM,CAClC,CACD,CACD,CAKAd,EAAO,QAAUI,ICrEjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isPositiveInteger", "format", "curryRight", "fcn", "arity", "thisArg", "context", "len", "createCurried", "args", "curried", "v", "cargs", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7271aed..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,53 +0,0 @@ - -{{alias}}( fcn[, arity][, thisArg] ) - Transforms a function into a sequence of functions each accepting a single - argument. - - Until return value resolution, each invocation returns a new partially - applied curry function. - - This function applies arguments starting from the right. - - Parameters - ---------- - fcn: Function - Function to curry. - - arity: integer (optional) - Number of parameters. Default: `fcn.length`. - - thisArg: any (optional) - Evaluation context. - - Returns - ------- - out: Function - Curry function. - - Examples - -------- - > function add( x, y ) { return x + y; }; - > var f = {{alias}}( add ); - > var sum = f( 2 )( 3 ) - 5 - - // Supply arity: - > function add() { return arguments[ 0 ] + arguments[ 1 ]; }; - > f = {{alias}}( add, 2 ); - > sum = f( 2 )( 3 ) - 5 - - // Provide function context: - > var obj = { - ... 'name': 'Ada', - ... 'greet': function greet( word1, word2 ) { - ... return word1 + ' ' + word2 + ', ' + this.name + '!' - ... } - ... }; - > f = {{alias}}( obj.greet, obj ); - > var str = f( 'there' )( 'Hello' ) - 'Hello there, Ada!' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4577cdb..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,71 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import curryRight = require( './index' ); - - -// TESTS // - -// The function returns a function... -{ - curryRight( ( x: number, y: number ): number => x + y ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: number, y: number ): number => x + y, 2 ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: number, y: number ): number => x + y, 2, {} ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: string, y: string ): string => x + y, {} ); // $ExpectType (v: string) => (v: string) => string - curryRight( ( x: string, y: string ): string => x + y, 2, {} ); // $ExpectType (v: string) => (v: string) => string - curryRight( ( str: string, n: number ): string => str.substring( n ) ); // $ExpectType (v: number) => (v: string) => string - - const cxt = { - 'count': 0, - 'multiply': function multiply( this: { count: number }, x: number, y: number ): number { - this.count += 1; // eslint-disable-line no-invalid-this - return x * y; - } - }; - curryRight( cxt.multiply ); // $ExpectType (v: number) => (v: number) => number - curryRight( cxt.multiply, 2 ); // $ExpectType (v: number) => (v: number) => number - curryRight( cxt.multiply, 2, { 'count': 2 } ); // $ExpectType (v: number) => (v: number) => number -} - -// The compiler throws an error if the function is provided a first argument other than a function... -{ - curryRight( true ); // $ExpectError - curryRight( false ); // $ExpectError - curryRight( 5 ); // $ExpectError - curryRight( [] ); // $ExpectError - curryRight( {} ); // $ExpectError - curryRight( 'abc' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a this argument which does not constitute a valid `this` context... -{ - const cxt = { - 'count': 0, - 'multiply': function multiply( this: { count: number }, x: number, y: number ): number { - this.count += 1; // eslint-disable-line no-invalid-this - return x * y; - } - }; - curryRight( cxt.multiply, { 'COUNT': 2 } ); // $ExpectError - curryRight( cxt.multiply, 2, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided more than three arguments... -{ - curryRight( ( x: number, y: number ): number => x + y, 2, {}, 4 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 76818ec..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 curryRight = require( './../lib' ); - -var fcn; -var out; -var i; - -function add( x, y, z, w, t, s ) { - return x + y + z + w + t + s; -} - -fcn = curryRight( add ); -out = fcn; -for ( i = 0; i < add.length; i++ ) { - out = out( i*10 ); -} -console.log( out ); 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..0d7e48e --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@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 s(s,n,i){var o,l;if(!e(s))throw new TypeError(t("1SN3c",s));if(arguments.length<2){if(l=s.length,!r(l))throw new TypeError(t("1SNEX",l))}else if(arguments.length>2){if(o=i,!r(l=n))throw new TypeError(t("1SNAz",l))}else if(r(n))l=n;else{if(l=s.length,!r(l))throw new TypeError(t("1SNEX",l));o=n}return function e(r){return t;function t(t){var n=r.slice();return n.unshift(t),n.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNAz', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNEX', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","curried","v","cargs","slice","unshift","apply"],"mappings":";;kTAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,SAEjC,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAEjC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvCD,EAAUF,CACV,CACD,OASA,SAASU,EAAeC,GACvB,OAAOC,EASP,SAASA,EAASC,GACjB,IAAIC,EAAQH,EAAKI,QAEjB,OADAD,EAAME,QAASH,GACVC,EAAMN,OAASL,EACZO,EAAeI,GAEhBf,EAAIkB,MAAOf,EAASY,EAC3B,CACD,CA3BMJ,CAAe,GA4BvB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 7e7d2e8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform a function into a sequence of functions each accepting a single argument. -* -* @module @stdlib/utils-curry-right -* -* @example -* var curryRight = require( '@stdlib/utils-curry-right' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ - -// 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 ffb671a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* @param {Function} fcn - function to curry -* @param {PositiveInteger} [arity=fcn.length] - number of parameters -* @param {*} [thisArg] - evaluation context -* @throws {TypeError} first argument must be a function -* @throws {TypeError} first argument must be a function having at least one parameter -* @throws {TypeError} `arity` argument must be a positive integer -* @returns {Function} curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -function curryRight( fcn, arity, thisArg ) { - var context; - var len; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '1SN3c', fcn ) ); - } - if ( arguments.length < 2 ) { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNEX', len ) ); - } - } else if ( arguments.length > 2 ) { - len = arity; - context = thisArg; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNAz', len ) ); - } - } else if ( isPositiveInteger( arity ) ) { - len = arity; - } else { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNEX', len ) ); - } - context = arity; - } - return createCurried( [] ); - - /** - * Returns a curry function. - * - * @private - * @param {Array} args - arguments - * @returns {Function} curry function - */ - function createCurried( args ) { - return curried; - - /** - * Curry function. - * - * @private - * @param {*} v - curried function parameter - * @returns {(Function|*)} partially applied curry function or curried function result - */ - function curried( v ) { - var cargs = args.slice(); - cargs.unshift( v ); - if ( cargs.length < len ) { - return createCurried( cargs ); - } - return fcn.apply( context, cargs ); - } - } -} - - -// EXPORTS // - -module.exports = curryRight; diff --git a/package.json b/package.json index 725e56a..be38e0f 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Transform a function into a sequence of functions each accepting a single argument.", "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/assert-is-positive-integer": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/math-base-ops-add3": "^0.2.1", - "@stdlib/math-base-special-pow": "^0.2.1", - "@stdlib/random-base-randu": "^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..66324aa --- /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 3f1273f..0000000 --- a/test/test.js +++ /dev/null @@ -1,285 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var add = require( '@stdlib/math-base-ops-add3' ); -var curryRight = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof curryRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (1 arg)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (2 args; context)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an arity argument which is not a positive integer (3 args)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - 0, - -1, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( add, value, {} ); - }; - } -}); - -tape( 'the function returns a function', function test( t ) { - var fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function curries a function', function test( t) { - var fcn; - var f; - - fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'for each invocation where the invocation number is less than the arity, the curried function returns a new partially applied curry function', function test( t ) { - var sum; - var f0; - var f1; - var f2; - - // Initial curried function has no partially applied arguments... - f0 = curryRight( add ); - - sum = f0( 1 )( 2 )( 3 ); - t.strictEqual( sum, 6, 'returns 6' ); - - sum = f0( 1 )( 3 )( 5 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f0( 10 )( 20 )( 40 ); - t.strictEqual( sum, 70, 'returns 70' ); - - // If arity greater than 1, first invocation returns a curried function with one partially applied argument... - f1 = f0( 2 ); - - sum = f1( 3 )( 4 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f1( 10 )( 20 ); - t.strictEqual( sum, 32, 'returns 32' ); - - sum = f1( -1 )( -2 ); - t.strictEqual( sum, -1, 'returns -1' ); - - // If arity greater than 2, second invocation returns a curried function with two partially applied arguments... - f2 = f1( 3 ); - - sum = f2( 5 ); - t.strictEqual( sum, 10, 'returns 10' ); - - sum = f2( 6 ); - t.strictEqual( sum, 11, 'returns 11' ); - - sum = f2( 10 ); - t.strictEqual( sum, 15, 'returns 15' ); - - // And so on and so forth... - - t.end(); -}); - -tape( 'the function supports specifying a function arity', function test( t ) { - var fcn; - var f; - - function add() { - return arguments[ 0 ] + arguments[ 1 ] + arguments[ 2 ]; - } - - fcn = curryRight( add, 3 ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'the function supports specifying a function context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate( length, units, type, color ) { - return this.style+': '+length+units+' '+type+' '+color; - } - }; - - fcn = curryRight( context.generate, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); - -tape( 'the function supports specifying a function arity and context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate() { - return this.style+': '+arguments[0]+arguments[1]+' '+arguments[2]+' '+arguments[3]; - } - }; - - fcn = curryRight( context.generate, 4, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); From 27fcb6cd6996249c5334ba9e701cc67ad2838239 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 03:31:35 +0000 Subject: [PATCH 098/140] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index 8d7768e..ffb671a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -52,25 +52,25 @@ function curryRight( fcn, arity, thisArg ) { var context; var len; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '1SN3c', fcn ) ); } if ( arguments.length < 2 ) { len = fcn.length; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); + throw new TypeError( format( '1SNEX', len ) ); } } else if ( arguments.length > 2 ) { len = arity; context = thisArg; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) ); + throw new TypeError( format( '1SNAz', len ) ); } } else if ( isPositiveInteger( arity ) ) { len = arity; } else { len = fcn.length; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); + throw new TypeError( format( '1SNEX', len ) ); } context = arity; } diff --git a/package.json b/package.json index 412840c..725e56a 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-function": "^0.2.1", "@stdlib/assert-is-positive-integer": "^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 e56a30be8f31ae35e6e632336056d35ad58445f6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 07:33:23 +0000 Subject: [PATCH 099/140] Remove files --- index.d.ts | 116 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4963 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 a4e85ef..0000000 --- a/index.d.ts +++ /dev/null @@ -1,116 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Utility type to reverse a tuple type. -*/ -type ReverseTuple> = T extends [infer First, ...infer Rest] ? [...ReverseTuple, First] : []; // eslint-disable-line @typescript-eslint/no-explicit-any - -/** - * Curry function type for curryRight. - */ -type CurryRightFunction< - TThis, - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn -> = ( this: TThis, ...args: TArgs ) => TReturn; - -/** -* Curry function. -* -* @param v - curried function parameter -* @returns partially applied curry function or curried function result -*/ -type Closure< - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn -> = ReverseTuple extends [infer TFirst, ...infer TRest] - ? ( v: TFirst ) => Closure, TReturn> - : TReturn; - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param arity - number of parameters -* @param thisArg - evaluation context -* @throws `arity` must be a positive integer -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight< - TThis extends object, - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn ->( - fcn: CurryRightFunction, - arity: number, - thisArg?: TThis -): Closure; - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param thisArg - evaluation context -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight< - TThis extends object, - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn ->( - fcn: CurryRightFunction, - thisArg?: TThis -): Closure; - - -// EXPORTS // - -export = curryRight; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 0d7e48e..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@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 s(s,n,i){var o,l;if(!e(s))throw new TypeError(t("1SN3c",s));if(arguments.length<2){if(l=s.length,!r(l))throw new TypeError(t("1SNEX",l))}else if(arguments.length>2){if(o=i,!r(l=n))throw new TypeError(t("1SNAz",l))}else if(r(n))l=n;else{if(l=s.length,!r(l))throw new TypeError(t("1SNEX",l));o=n}return function e(r){return t;function t(t){var n=r.slice();return n.unshift(t),n.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNAz', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNEX', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","curried","v","cargs","slice","unshift","apply"],"mappings":";;kTAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,SAEjC,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAEjC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvCD,EAAUF,CACV,CACD,OASA,SAASU,EAAeC,GACvB,OAAOC,EASP,SAASA,EAASC,GACjB,IAAIC,EAAQH,EAAKI,QAEjB,OADAD,EAAME,QAASH,GACVC,EAAMN,OAASL,EACZO,EAAeI,GAEhBf,EAAIkB,MAAOf,EAASY,EAC3B,CACD,CA3BMJ,CAAe,GA4BvB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 66324aa..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 1785aa4c53566dc9970311c1133ab34728e95ca8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 07:33:33 +0000 Subject: [PATCH 100/140] 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 | 41 +- SECURITY.md | 5 - benchmark/benchmark.js | 90 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 53 - docs/types/test.ts | 71 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 110 - package.json | 57 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 285 -- 43 files changed, 4865 insertions(+), 4046 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 18a87ae..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-04-01T02:21:57.016Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2b7fad0..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/curry-right) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 9ffcfa1..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/curry-right) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 906f5af..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: '6 18 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index ec90164..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -260,7 +251,7 @@ console.log( out ); ## 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]. @@ -325,11 +316,11 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry +[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry/tree/esm -[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry +[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry/tree/esm -[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right +[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right/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 69ca868..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isFunction = require( '@stdlib/assert-is-function' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var curryRight = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = curryRight( pow ); - if ( typeof out !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( out ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::returned_function', function benchmark( b ) { - var fcn; - var out; - var i; - - fcn = curryRight( pow ); - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = fcn( randu() )( randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::direct', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = pow( randu(), randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 7ef3db2..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/curry-right" -%% click B href "https://github.com/stdlib-js/utils-curry-right/tree/main" -%% click C href "https://github.com/stdlib-js/utils-curry-right/tree/production" -%% click D href "https://github.com/stdlib-js/utils-curry-right/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-curry-right/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-curry-right/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/curry-right -[production-url]: https://github.com/stdlib-js/utils-curry-right/tree/production -[deno-url]: https://github.com/stdlib-js/utils-curry-right/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-curry-right/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-curry-right/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-curry-right/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-curry-right/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-curry-right/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 8166962..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import curryRight from '../docs/types/index'; -export = curryRight; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 16477e0..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var g=f(function(b,o){ -var c=require('@stdlib/assert-is-function/dist'),n=require('@stdlib/assert-is-positive-integer/dist').isPrimitive,a=require('@stdlib/error-tools-fmtprodmsg/dist');function p(t,r,l){var u,e;if(!c(t))throw new TypeError(a('1SN3c',t));if(arguments.length<2){if(e=t.length,!n(e))throw new TypeError(a('1SNEX',e))}else if(arguments.length>2){if(e=r,u=l,!n(e))throw new TypeError(a('1SNAz',e))}else if(n(r))e=r;else{if(e=t.length,!n(e))throw new TypeError(a('1SNEX',e));u=r}return s([]);function s(m){return v;function v(h){var i=m.slice();return i.unshift(h),i.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = curryRight;\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* Transform a function into a sequence of functions each accepting a single argument.\n*\n* @module @stdlib/utils-curry-right\n*\n* @example\n* var curryRight = require( '@stdlib/utils-curry-right' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var f = curryRight( add );\n*\n* var sum = f( 2 )( 3 );\n* // returns 5\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,EAAoB,QAAS,oCAAqC,EAAE,YACpEC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,EAAYC,EAAKC,EAAOC,EAAU,CAC1C,IAAIC,EACAC,EACJ,GAAK,CAACR,EAAYI,CAAI,EACrB,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAI,CAAE,EAEzG,GAAK,UAAU,OAAS,GAEvB,GADAI,EAAMJ,EAAI,OACL,CAACH,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,kGAAmGM,CAAI,CAAE,UAE5H,UAAU,OAAS,GAG9B,GAFAA,EAAMH,EACNE,EAAUD,EACL,CAACL,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,4EAA6EM,CAAI,CAAE,UAEtGP,EAAmBI,CAAM,EACpCG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAI,OACL,CAACH,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,kGAAmGM,CAAI,CAAE,EAEvID,EAAUF,CACX,CACA,OAAOI,EAAe,CAAC,CAAE,EASzB,SAASA,EAAeC,EAAO,CAC9B,OAAOC,EASP,SAASA,EAASC,EAAI,CACrB,IAAIC,EAAQH,EAAK,MAAM,EAEvB,OADAG,EAAM,QAASD,CAAE,EACZC,EAAM,OAASL,EACZC,EAAeI,CAAM,EAEtBT,EAAI,MAAOG,EAASM,CAAM,CAClC,CACD,CACD,CAKAd,EAAO,QAAUI,ICrEjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isPositiveInteger", "format", "curryRight", "fcn", "arity", "thisArg", "context", "len", "createCurried", "args", "curried", "v", "cargs", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7271aed..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,53 +0,0 @@ - -{{alias}}( fcn[, arity][, thisArg] ) - Transforms a function into a sequence of functions each accepting a single - argument. - - Until return value resolution, each invocation returns a new partially - applied curry function. - - This function applies arguments starting from the right. - - Parameters - ---------- - fcn: Function - Function to curry. - - arity: integer (optional) - Number of parameters. Default: `fcn.length`. - - thisArg: any (optional) - Evaluation context. - - Returns - ------- - out: Function - Curry function. - - Examples - -------- - > function add( x, y ) { return x + y; }; - > var f = {{alias}}( add ); - > var sum = f( 2 )( 3 ) - 5 - - // Supply arity: - > function add() { return arguments[ 0 ] + arguments[ 1 ]; }; - > f = {{alias}}( add, 2 ); - > sum = f( 2 )( 3 ) - 5 - - // Provide function context: - > var obj = { - ... 'name': 'Ada', - ... 'greet': function greet( word1, word2 ) { - ... return word1 + ' ' + word2 + ', ' + this.name + '!' - ... } - ... }; - > f = {{alias}}( obj.greet, obj ); - > var str = f( 'there' )( 'Hello' ) - 'Hello there, Ada!' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4577cdb..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,71 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import curryRight = require( './index' ); - - -// TESTS // - -// The function returns a function... -{ - curryRight( ( x: number, y: number ): number => x + y ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: number, y: number ): number => x + y, 2 ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: number, y: number ): number => x + y, 2, {} ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: string, y: string ): string => x + y, {} ); // $ExpectType (v: string) => (v: string) => string - curryRight( ( x: string, y: string ): string => x + y, 2, {} ); // $ExpectType (v: string) => (v: string) => string - curryRight( ( str: string, n: number ): string => str.substring( n ) ); // $ExpectType (v: number) => (v: string) => string - - const cxt = { - 'count': 0, - 'multiply': function multiply( this: { count: number }, x: number, y: number ): number { - this.count += 1; // eslint-disable-line no-invalid-this - return x * y; - } - }; - curryRight( cxt.multiply ); // $ExpectType (v: number) => (v: number) => number - curryRight( cxt.multiply, 2 ); // $ExpectType (v: number) => (v: number) => number - curryRight( cxt.multiply, 2, { 'count': 2 } ); // $ExpectType (v: number) => (v: number) => number -} - -// The compiler throws an error if the function is provided a first argument other than a function... -{ - curryRight( true ); // $ExpectError - curryRight( false ); // $ExpectError - curryRight( 5 ); // $ExpectError - curryRight( [] ); // $ExpectError - curryRight( {} ); // $ExpectError - curryRight( 'abc' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a this argument which does not constitute a valid `this` context... -{ - const cxt = { - 'count': 0, - 'multiply': function multiply( this: { count: number }, x: number, y: number ): number { - this.count += 1; // eslint-disable-line no-invalid-this - return x * y; - } - }; - curryRight( cxt.multiply, { 'COUNT': 2 } ); // $ExpectError - curryRight( cxt.multiply, 2, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided more than three arguments... -{ - curryRight( ( x: number, y: number ): number => x + y, 2, {}, 4 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 76818ec..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 curryRight = require( './../lib' ); - -var fcn; -var out; -var i; - -function add( x, y, z, w, t, s ) { - return x + y + z + w + t + s; -} - -fcn = curryRight( add ); -out = fcn; -for ( i = 0; i < add.length; i++ ) { - out = out( i*10 ); -} -console.log( out ); 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..0d7e48e --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@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 s(s,n,i){var o,l;if(!e(s))throw new TypeError(t("1SN3c",s));if(arguments.length<2){if(l=s.length,!r(l))throw new TypeError(t("1SNEX",l))}else if(arguments.length>2){if(o=i,!r(l=n))throw new TypeError(t("1SNAz",l))}else if(r(n))l=n;else{if(l=s.length,!r(l))throw new TypeError(t("1SNEX",l));o=n}return function e(r){return t;function t(t){var n=r.slice();return n.unshift(t),n.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNAz', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNEX', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","curried","v","cargs","slice","unshift","apply"],"mappings":";;kTAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,SAEjC,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAEjC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvCD,EAAUF,CACV,CACD,OASA,SAASU,EAAeC,GACvB,OAAOC,EASP,SAASA,EAASC,GACjB,IAAIC,EAAQH,EAAKI,QAEjB,OADAD,EAAME,QAASH,GACVC,EAAMN,OAASL,EACZO,EAAeI,GAEhBf,EAAIkB,MAAOf,EAASY,EAC3B,CACD,CA3BMJ,CAAe,GA4BvB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 7e7d2e8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform a function into a sequence of functions each accepting a single argument. -* -* @module @stdlib/utils-curry-right -* -* @example -* var curryRight = require( '@stdlib/utils-curry-right' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ - -// 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 ffb671a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* @param {Function} fcn - function to curry -* @param {PositiveInteger} [arity=fcn.length] - number of parameters -* @param {*} [thisArg] - evaluation context -* @throws {TypeError} first argument must be a function -* @throws {TypeError} first argument must be a function having at least one parameter -* @throws {TypeError} `arity` argument must be a positive integer -* @returns {Function} curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -function curryRight( fcn, arity, thisArg ) { - var context; - var len; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '1SN3c', fcn ) ); - } - if ( arguments.length < 2 ) { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNEX', len ) ); - } - } else if ( arguments.length > 2 ) { - len = arity; - context = thisArg; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNAz', len ) ); - } - } else if ( isPositiveInteger( arity ) ) { - len = arity; - } else { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNEX', len ) ); - } - context = arity; - } - return createCurried( [] ); - - /** - * Returns a curry function. - * - * @private - * @param {Array} args - arguments - * @returns {Function} curry function - */ - function createCurried( args ) { - return curried; - - /** - * Curry function. - * - * @private - * @param {*} v - curried function parameter - * @returns {(Function|*)} partially applied curry function or curried function result - */ - function curried( v ) { - var cargs = args.slice(); - cargs.unshift( v ); - if ( cargs.length < len ) { - return createCurried( cargs ); - } - return fcn.apply( context, cargs ); - } - } -} - - -// EXPORTS // - -module.exports = curryRight; diff --git a/package.json b/package.json index 725e56a..be38e0f 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Transform a function into a sequence of functions each accepting a single argument.", "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/assert-is-positive-integer": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/math-base-ops-add3": "^0.2.1", - "@stdlib/math-base-special-pow": "^0.2.1", - "@stdlib/random-base-randu": "^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..66324aa --- /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 3f1273f..0000000 --- a/test/test.js +++ /dev/null @@ -1,285 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var add = require( '@stdlib/math-base-ops-add3' ); -var curryRight = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof curryRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (1 arg)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (2 args; context)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an arity argument which is not a positive integer (3 args)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - 0, - -1, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( add, value, {} ); - }; - } -}); - -tape( 'the function returns a function', function test( t ) { - var fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function curries a function', function test( t) { - var fcn; - var f; - - fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'for each invocation where the invocation number is less than the arity, the curried function returns a new partially applied curry function', function test( t ) { - var sum; - var f0; - var f1; - var f2; - - // Initial curried function has no partially applied arguments... - f0 = curryRight( add ); - - sum = f0( 1 )( 2 )( 3 ); - t.strictEqual( sum, 6, 'returns 6' ); - - sum = f0( 1 )( 3 )( 5 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f0( 10 )( 20 )( 40 ); - t.strictEqual( sum, 70, 'returns 70' ); - - // If arity greater than 1, first invocation returns a curried function with one partially applied argument... - f1 = f0( 2 ); - - sum = f1( 3 )( 4 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f1( 10 )( 20 ); - t.strictEqual( sum, 32, 'returns 32' ); - - sum = f1( -1 )( -2 ); - t.strictEqual( sum, -1, 'returns -1' ); - - // If arity greater than 2, second invocation returns a curried function with two partially applied arguments... - f2 = f1( 3 ); - - sum = f2( 5 ); - t.strictEqual( sum, 10, 'returns 10' ); - - sum = f2( 6 ); - t.strictEqual( sum, 11, 'returns 11' ); - - sum = f2( 10 ); - t.strictEqual( sum, 15, 'returns 15' ); - - // And so on and so forth... - - t.end(); -}); - -tape( 'the function supports specifying a function arity', function test( t ) { - var fcn; - var f; - - function add() { - return arguments[ 0 ] + arguments[ 1 ] + arguments[ 2 ]; - } - - fcn = curryRight( add, 3 ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'the function supports specifying a function context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate( length, units, type, color ) { - return this.style+': '+length+units+' '+type+' '+color; - } - }; - - fcn = curryRight( context.generate, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); - -tape( 'the function supports specifying a function arity and context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate() { - return this.style+': '+arguments[0]+arguments[1]+' '+arguments[2]+' '+arguments[3]; - } - }; - - fcn = curryRight( context.generate, 4, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); From 7125b3537d927bbdb6f5989be1c8a3094744809d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 11 Apr 2024 23:40:16 +0000 Subject: [PATCH 101/140] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index 8d7768e..ffb671a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -52,25 +52,25 @@ function curryRight( fcn, arity, thisArg ) { var context; var len; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '1SN3c', fcn ) ); } if ( arguments.length < 2 ) { len = fcn.length; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); + throw new TypeError( format( '1SNEX', len ) ); } } else if ( arguments.length > 2 ) { len = arity; context = thisArg; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) ); + throw new TypeError( format( '1SNAz', len ) ); } } else if ( isPositiveInteger( arity ) ) { len = arity; } else { len = fcn.length; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); + throw new TypeError( format( '1SNEX', len ) ); } context = arity; } diff --git a/package.json b/package.json index 412840c..725e56a 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-function": "^0.2.1", "@stdlib/assert-is-positive-integer": "^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 1fb4ef4a123efb88a6c0a8a9aed480920e535572 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 04:21:52 +0000 Subject: [PATCH 102/140] Remove files --- index.d.ts | 116 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4963 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 a4e85ef..0000000 --- a/index.d.ts +++ /dev/null @@ -1,116 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Utility type to reverse a tuple type. -*/ -type ReverseTuple> = T extends [infer First, ...infer Rest] ? [...ReverseTuple, First] : []; // eslint-disable-line @typescript-eslint/no-explicit-any - -/** - * Curry function type for curryRight. - */ -type CurryRightFunction< - TThis, - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn -> = ( this: TThis, ...args: TArgs ) => TReturn; - -/** -* Curry function. -* -* @param v - curried function parameter -* @returns partially applied curry function or curried function result -*/ -type Closure< - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn -> = ReverseTuple extends [infer TFirst, ...infer TRest] - ? ( v: TFirst ) => Closure, TReturn> - : TReturn; - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param arity - number of parameters -* @param thisArg - evaluation context -* @throws `arity` must be a positive integer -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight< - TThis extends object, - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn ->( - fcn: CurryRightFunction, - arity: number, - thisArg?: TThis -): Closure; - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param thisArg - evaluation context -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight< - TThis extends object, - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn ->( - fcn: CurryRightFunction, - thisArg?: TThis -): Closure; - - -// EXPORTS // - -export = curryRight; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 0d7e48e..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@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 s(s,n,i){var o,l;if(!e(s))throw new TypeError(t("1SN3c",s));if(arguments.length<2){if(l=s.length,!r(l))throw new TypeError(t("1SNEX",l))}else if(arguments.length>2){if(o=i,!r(l=n))throw new TypeError(t("1SNAz",l))}else if(r(n))l=n;else{if(l=s.length,!r(l))throw new TypeError(t("1SNEX",l));o=n}return function e(r){return t;function t(t){var n=r.slice();return n.unshift(t),n.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNAz', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNEX', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","curried","v","cargs","slice","unshift","apply"],"mappings":";;kTAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,SAEjC,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAEjC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvCD,EAAUF,CACV,CACD,OASA,SAASU,EAAeC,GACvB,OAAOC,EASP,SAASA,EAASC,GACjB,IAAIC,EAAQH,EAAKI,QAEjB,OADAD,EAAME,QAASH,GACVC,EAAMN,OAASL,EACZO,EAAeI,GAEhBf,EAAIkB,MAAOf,EAASY,EAC3B,CACD,CA3BMJ,CAAe,GA4BvB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 66324aa..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 761c843e6f05401b600fefcbc4c6f454ba651410 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 04:22:10 +0000 Subject: [PATCH 103/140] 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 | 41 +- SECURITY.md | 5 - benchmark/benchmark.js | 90 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 53 - docs/types/test.ts | 71 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 110 - package.json | 57 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 285 -- 42 files changed, 4865 insertions(+), 4047 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 2b7fad0..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/curry-right) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 9ffcfa1..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/curry-right) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 906f5af..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: '6 18 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index ec90164..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -260,7 +251,7 @@ console.log( out ); ## 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]. @@ -325,11 +316,11 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry +[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry/tree/esm -[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry +[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry/tree/esm -[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right +[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right/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 69ca868..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isFunction = require( '@stdlib/assert-is-function' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var curryRight = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = curryRight( pow ); - if ( typeof out !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( out ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::returned_function', function benchmark( b ) { - var fcn; - var out; - var i; - - fcn = curryRight( pow ); - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = fcn( randu() )( randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::direct', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = pow( randu(), randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 7ef3db2..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/curry-right" -%% click B href "https://github.com/stdlib-js/utils-curry-right/tree/main" -%% click C href "https://github.com/stdlib-js/utils-curry-right/tree/production" -%% click D href "https://github.com/stdlib-js/utils-curry-right/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-curry-right/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-curry-right/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/curry-right -[production-url]: https://github.com/stdlib-js/utils-curry-right/tree/production -[deno-url]: https://github.com/stdlib-js/utils-curry-right/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-curry-right/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-curry-right/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-curry-right/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-curry-right/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-curry-right/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 8166962..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import curryRight from '../docs/types/index'; -export = curryRight; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 16477e0..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var g=f(function(b,o){ -var c=require('@stdlib/assert-is-function/dist'),n=require('@stdlib/assert-is-positive-integer/dist').isPrimitive,a=require('@stdlib/error-tools-fmtprodmsg/dist');function p(t,r,l){var u,e;if(!c(t))throw new TypeError(a('1SN3c',t));if(arguments.length<2){if(e=t.length,!n(e))throw new TypeError(a('1SNEX',e))}else if(arguments.length>2){if(e=r,u=l,!n(e))throw new TypeError(a('1SNAz',e))}else if(n(r))e=r;else{if(e=t.length,!n(e))throw new TypeError(a('1SNEX',e));u=r}return s([]);function s(m){return v;function v(h){var i=m.slice();return i.unshift(h),i.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = curryRight;\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* Transform a function into a sequence of functions each accepting a single argument.\n*\n* @module @stdlib/utils-curry-right\n*\n* @example\n* var curryRight = require( '@stdlib/utils-curry-right' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var f = curryRight( add );\n*\n* var sum = f( 2 )( 3 );\n* // returns 5\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,EAAoB,QAAS,oCAAqC,EAAE,YACpEC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,EAAYC,EAAKC,EAAOC,EAAU,CAC1C,IAAIC,EACAC,EACJ,GAAK,CAACR,EAAYI,CAAI,EACrB,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAI,CAAE,EAEzG,GAAK,UAAU,OAAS,GAEvB,GADAI,EAAMJ,EAAI,OACL,CAACH,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,kGAAmGM,CAAI,CAAE,UAE5H,UAAU,OAAS,GAG9B,GAFAA,EAAMH,EACNE,EAAUD,EACL,CAACL,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,4EAA6EM,CAAI,CAAE,UAEtGP,EAAmBI,CAAM,EACpCG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAI,OACL,CAACH,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,kGAAmGM,CAAI,CAAE,EAEvID,EAAUF,CACX,CACA,OAAOI,EAAe,CAAC,CAAE,EASzB,SAASA,EAAeC,EAAO,CAC9B,OAAOC,EASP,SAASA,EAASC,EAAI,CACrB,IAAIC,EAAQH,EAAK,MAAM,EAEvB,OADAG,EAAM,QAASD,CAAE,EACZC,EAAM,OAASL,EACZC,EAAeI,CAAM,EAEtBT,EAAI,MAAOG,EAASM,CAAM,CAClC,CACD,CACD,CAKAd,EAAO,QAAUI,ICrEjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isPositiveInteger", "format", "curryRight", "fcn", "arity", "thisArg", "context", "len", "createCurried", "args", "curried", "v", "cargs", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7271aed..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,53 +0,0 @@ - -{{alias}}( fcn[, arity][, thisArg] ) - Transforms a function into a sequence of functions each accepting a single - argument. - - Until return value resolution, each invocation returns a new partially - applied curry function. - - This function applies arguments starting from the right. - - Parameters - ---------- - fcn: Function - Function to curry. - - arity: integer (optional) - Number of parameters. Default: `fcn.length`. - - thisArg: any (optional) - Evaluation context. - - Returns - ------- - out: Function - Curry function. - - Examples - -------- - > function add( x, y ) { return x + y; }; - > var f = {{alias}}( add ); - > var sum = f( 2 )( 3 ) - 5 - - // Supply arity: - > function add() { return arguments[ 0 ] + arguments[ 1 ]; }; - > f = {{alias}}( add, 2 ); - > sum = f( 2 )( 3 ) - 5 - - // Provide function context: - > var obj = { - ... 'name': 'Ada', - ... 'greet': function greet( word1, word2 ) { - ... return word1 + ' ' + word2 + ', ' + this.name + '!' - ... } - ... }; - > f = {{alias}}( obj.greet, obj ); - > var str = f( 'there' )( 'Hello' ) - 'Hello there, Ada!' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4577cdb..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,71 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import curryRight = require( './index' ); - - -// TESTS // - -// The function returns a function... -{ - curryRight( ( x: number, y: number ): number => x + y ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: number, y: number ): number => x + y, 2 ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: number, y: number ): number => x + y, 2, {} ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: string, y: string ): string => x + y, {} ); // $ExpectType (v: string) => (v: string) => string - curryRight( ( x: string, y: string ): string => x + y, 2, {} ); // $ExpectType (v: string) => (v: string) => string - curryRight( ( str: string, n: number ): string => str.substring( n ) ); // $ExpectType (v: number) => (v: string) => string - - const cxt = { - 'count': 0, - 'multiply': function multiply( this: { count: number }, x: number, y: number ): number { - this.count += 1; // eslint-disable-line no-invalid-this - return x * y; - } - }; - curryRight( cxt.multiply ); // $ExpectType (v: number) => (v: number) => number - curryRight( cxt.multiply, 2 ); // $ExpectType (v: number) => (v: number) => number - curryRight( cxt.multiply, 2, { 'count': 2 } ); // $ExpectType (v: number) => (v: number) => number -} - -// The compiler throws an error if the function is provided a first argument other than a function... -{ - curryRight( true ); // $ExpectError - curryRight( false ); // $ExpectError - curryRight( 5 ); // $ExpectError - curryRight( [] ); // $ExpectError - curryRight( {} ); // $ExpectError - curryRight( 'abc' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a this argument which does not constitute a valid `this` context... -{ - const cxt = { - 'count': 0, - 'multiply': function multiply( this: { count: number }, x: number, y: number ): number { - this.count += 1; // eslint-disable-line no-invalid-this - return x * y; - } - }; - curryRight( cxt.multiply, { 'COUNT': 2 } ); // $ExpectError - curryRight( cxt.multiply, 2, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided more than three arguments... -{ - curryRight( ( x: number, y: number ): number => x + y, 2, {}, 4 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 76818ec..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 curryRight = require( './../lib' ); - -var fcn; -var out; -var i; - -function add( x, y, z, w, t, s ) { - return x + y + z + w + t + s; -} - -fcn = curryRight( add ); -out = fcn; -for ( i = 0; i < add.length; i++ ) { - out = out( i*10 ); -} -console.log( out ); 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..0d7e48e --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@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 s(s,n,i){var o,l;if(!e(s))throw new TypeError(t("1SN3c",s));if(arguments.length<2){if(l=s.length,!r(l))throw new TypeError(t("1SNEX",l))}else if(arguments.length>2){if(o=i,!r(l=n))throw new TypeError(t("1SNAz",l))}else if(r(n))l=n;else{if(l=s.length,!r(l))throw new TypeError(t("1SNEX",l));o=n}return function e(r){return t;function t(t){var n=r.slice();return n.unshift(t),n.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNAz', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNEX', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","curried","v","cargs","slice","unshift","apply"],"mappings":";;kTAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,SAEjC,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAEjC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvCD,EAAUF,CACV,CACD,OASA,SAASU,EAAeC,GACvB,OAAOC,EASP,SAASA,EAASC,GACjB,IAAIC,EAAQH,EAAKI,QAEjB,OADAD,EAAME,QAASH,GACVC,EAAMN,OAASL,EACZO,EAAeI,GAEhBf,EAAIkB,MAAOf,EAASY,EAC3B,CACD,CA3BMJ,CAAe,GA4BvB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 7e7d2e8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform a function into a sequence of functions each accepting a single argument. -* -* @module @stdlib/utils-curry-right -* -* @example -* var curryRight = require( '@stdlib/utils-curry-right' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ - -// 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 ffb671a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* @param {Function} fcn - function to curry -* @param {PositiveInteger} [arity=fcn.length] - number of parameters -* @param {*} [thisArg] - evaluation context -* @throws {TypeError} first argument must be a function -* @throws {TypeError} first argument must be a function having at least one parameter -* @throws {TypeError} `arity` argument must be a positive integer -* @returns {Function} curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -function curryRight( fcn, arity, thisArg ) { - var context; - var len; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '1SN3c', fcn ) ); - } - if ( arguments.length < 2 ) { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNEX', len ) ); - } - } else if ( arguments.length > 2 ) { - len = arity; - context = thisArg; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNAz', len ) ); - } - } else if ( isPositiveInteger( arity ) ) { - len = arity; - } else { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNEX', len ) ); - } - context = arity; - } - return createCurried( [] ); - - /** - * Returns a curry function. - * - * @private - * @param {Array} args - arguments - * @returns {Function} curry function - */ - function createCurried( args ) { - return curried; - - /** - * Curry function. - * - * @private - * @param {*} v - curried function parameter - * @returns {(Function|*)} partially applied curry function or curried function result - */ - function curried( v ) { - var cargs = args.slice(); - cargs.unshift( v ); - if ( cargs.length < len ) { - return createCurried( cargs ); - } - return fcn.apply( context, cargs ); - } - } -} - - -// EXPORTS // - -module.exports = curryRight; diff --git a/package.json b/package.json index 725e56a..be38e0f 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Transform a function into a sequence of functions each accepting a single argument.", "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/assert-is-positive-integer": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/math-base-ops-add3": "^0.2.1", - "@stdlib/math-base-special-pow": "^0.2.1", - "@stdlib/random-base-randu": "^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..66324aa --- /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 3f1273f..0000000 --- a/test/test.js +++ /dev/null @@ -1,285 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var add = require( '@stdlib/math-base-ops-add3' ); -var curryRight = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof curryRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (1 arg)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (2 args; context)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an arity argument which is not a positive integer (3 args)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - 0, - -1, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( add, value, {} ); - }; - } -}); - -tape( 'the function returns a function', function test( t ) { - var fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function curries a function', function test( t) { - var fcn; - var f; - - fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'for each invocation where the invocation number is less than the arity, the curried function returns a new partially applied curry function', function test( t ) { - var sum; - var f0; - var f1; - var f2; - - // Initial curried function has no partially applied arguments... - f0 = curryRight( add ); - - sum = f0( 1 )( 2 )( 3 ); - t.strictEqual( sum, 6, 'returns 6' ); - - sum = f0( 1 )( 3 )( 5 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f0( 10 )( 20 )( 40 ); - t.strictEqual( sum, 70, 'returns 70' ); - - // If arity greater than 1, first invocation returns a curried function with one partially applied argument... - f1 = f0( 2 ); - - sum = f1( 3 )( 4 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f1( 10 )( 20 ); - t.strictEqual( sum, 32, 'returns 32' ); - - sum = f1( -1 )( -2 ); - t.strictEqual( sum, -1, 'returns -1' ); - - // If arity greater than 2, second invocation returns a curried function with two partially applied arguments... - f2 = f1( 3 ); - - sum = f2( 5 ); - t.strictEqual( sum, 10, 'returns 10' ); - - sum = f2( 6 ); - t.strictEqual( sum, 11, 'returns 11' ); - - sum = f2( 10 ); - t.strictEqual( sum, 15, 'returns 15' ); - - // And so on and so forth... - - t.end(); -}); - -tape( 'the function supports specifying a function arity', function test( t ) { - var fcn; - var f; - - function add() { - return arguments[ 0 ] + arguments[ 1 ] + arguments[ 2 ]; - } - - fcn = curryRight( add, 3 ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'the function supports specifying a function context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate( length, units, type, color ) { - return this.style+': '+length+units+' '+type+' '+color; - } - }; - - fcn = curryRight( context.generate, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); - -tape( 'the function supports specifying a function arity and context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate() { - return this.style+': '+arguments[0]+arguments[1]+' '+arguments[2]+' '+arguments[3]; - } - }; - - fcn = curryRight( context.generate, 4, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); From dcba63e3421b51dc974919293f127a212f84078b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 27 Jul 2024 18:32:50 +0000 Subject: [PATCH 104/140] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index 8d7768e..ffb671a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -52,25 +52,25 @@ function curryRight( fcn, arity, thisArg ) { var context; var len; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '1SN3c', fcn ) ); } if ( arguments.length < 2 ) { len = fcn.length; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); + throw new TypeError( format( '1SNEX', len ) ); } } else if ( arguments.length > 2 ) { len = arity; context = thisArg; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) ); + throw new TypeError( format( '1SNAz', len ) ); } } else if ( isPositiveInteger( arity ) ) { len = arity; } else { len = fcn.length; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); + throw new TypeError( format( '1SNEX', len ) ); } context = arity; } diff --git a/package.json b/package.json index 6ddaab0..07e31fc 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-function": "^0.2.2", "@stdlib/assert-is-positive-integer": "^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 b346575b2080c3a98dedd73ad3ff323ca266785f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 27 Jul 2024 18:33:43 +0000 Subject: [PATCH 105/140] Remove files --- index.d.ts | 116 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4963 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 a4e85ef..0000000 --- a/index.d.ts +++ /dev/null @@ -1,116 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Utility type to reverse a tuple type. -*/ -type ReverseTuple> = T extends [infer First, ...infer Rest] ? [...ReverseTuple, First] : []; // eslint-disable-line @typescript-eslint/no-explicit-any - -/** - * Curry function type for curryRight. - */ -type CurryRightFunction< - TThis, - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn -> = ( this: TThis, ...args: TArgs ) => TReturn; - -/** -* Curry function. -* -* @param v - curried function parameter -* @returns partially applied curry function or curried function result -*/ -type Closure< - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn -> = ReverseTuple extends [infer TFirst, ...infer TRest] - ? ( v: TFirst ) => Closure, TReturn> - : TReturn; - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param arity - number of parameters -* @param thisArg - evaluation context -* @throws `arity` must be a positive integer -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight< - TThis extends object, - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn ->( - fcn: CurryRightFunction, - arity: number, - thisArg?: TThis -): Closure; - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param thisArg - evaluation context -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight< - TThis extends object, - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn ->( - fcn: CurryRightFunction, - thisArg?: TThis -): Closure; - - -// EXPORTS // - -export = curryRight; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 0d7e48e..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.1-esm/index.mjs";import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@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 s(s,n,i){var o,l;if(!e(s))throw new TypeError(t("1SN3c",s));if(arguments.length<2){if(l=s.length,!r(l))throw new TypeError(t("1SNEX",l))}else if(arguments.length>2){if(o=i,!r(l=n))throw new TypeError(t("1SNAz",l))}else if(r(n))l=n;else{if(l=s.length,!r(l))throw new TypeError(t("1SNEX",l));o=n}return function e(r){return t;function t(t){var n=r.slice();return n.unshift(t),n.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNAz', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNEX', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","curried","v","cargs","slice","unshift","apply"],"mappings":";;kTAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,SAEjC,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAEjC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvCD,EAAUF,CACV,CACD,OASA,SAASU,EAAeC,GACvB,OAAOC,EASP,SAASA,EAASC,GACjB,IAAIC,EAAQH,EAAKI,QAEjB,OADAD,EAAME,QAASH,GACVC,EAAMN,OAASL,EACZO,EAAeI,GAEhBf,EAAIkB,MAAOf,EAASY,EAC3B,CACD,CA3BMJ,CAAe,GA4BvB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 66324aa..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 3d71ac0453b12a9445802954d23132a549c75f2c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 27 Jul 2024 18:33:58 +0000 Subject: [PATCH 106/140] 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 | 209 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 41 +- SECURITY.md | 5 - benchmark/benchmark.js | 90 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 53 - docs/types/test.ts | 71 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 110 - package.json | 57 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 285 -- 42 files changed, 4865 insertions(+), 4262 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .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 2b7fad0..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/curry-right) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 9ffcfa1..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/curry-right) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 906f5af..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: '6 18 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -260,7 +251,7 @@ console.log( out ); ## 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]. @@ -325,11 +316,11 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry +[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry/tree/esm -[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry +[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry/tree/esm -[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right +[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right/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 69ca868..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isFunction = require( '@stdlib/assert-is-function' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var curryRight = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = curryRight( pow ); - if ( typeof out !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( out ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::returned_function', function benchmark( b ) { - var fcn; - var out; - var i; - - fcn = curryRight( pow ); - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = fcn( randu() )( randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::direct', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = pow( randu(), randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 7ef3db2..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/curry-right" -%% click B href "https://github.com/stdlib-js/utils-curry-right/tree/main" -%% click C href "https://github.com/stdlib-js/utils-curry-right/tree/production" -%% click D href "https://github.com/stdlib-js/utils-curry-right/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-curry-right/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-curry-right/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/curry-right -[production-url]: https://github.com/stdlib-js/utils-curry-right/tree/production -[deno-url]: https://github.com/stdlib-js/utils-curry-right/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-curry-right/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-curry-right/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-curry-right/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-curry-right/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-curry-right/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 8166962..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import curryRight from '../docs/types/index'; -export = curryRight; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 16477e0..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var g=f(function(b,o){ -var c=require('@stdlib/assert-is-function/dist'),n=require('@stdlib/assert-is-positive-integer/dist').isPrimitive,a=require('@stdlib/error-tools-fmtprodmsg/dist');function p(t,r,l){var u,e;if(!c(t))throw new TypeError(a('1SN3c',t));if(arguments.length<2){if(e=t.length,!n(e))throw new TypeError(a('1SNEX',e))}else if(arguments.length>2){if(e=r,u=l,!n(e))throw new TypeError(a('1SNAz',e))}else if(n(r))e=r;else{if(e=t.length,!n(e))throw new TypeError(a('1SNEX',e));u=r}return s([]);function s(m){return v;function v(h){var i=m.slice();return i.unshift(h),i.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = curryRight;\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* Transform a function into a sequence of functions each accepting a single argument.\n*\n* @module @stdlib/utils-curry-right\n*\n* @example\n* var curryRight = require( '@stdlib/utils-curry-right' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var f = curryRight( add );\n*\n* var sum = f( 2 )( 3 );\n* // returns 5\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,EAAoB,QAAS,oCAAqC,EAAE,YACpEC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,EAAYC,EAAKC,EAAOC,EAAU,CAC1C,IAAIC,EACAC,EACJ,GAAK,CAACR,EAAYI,CAAI,EACrB,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAI,CAAE,EAEzG,GAAK,UAAU,OAAS,GAEvB,GADAI,EAAMJ,EAAI,OACL,CAACH,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,kGAAmGM,CAAI,CAAE,UAE5H,UAAU,OAAS,GAG9B,GAFAA,EAAMH,EACNE,EAAUD,EACL,CAACL,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,4EAA6EM,CAAI,CAAE,UAEtGP,EAAmBI,CAAM,EACpCG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAI,OACL,CAACH,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,kGAAmGM,CAAI,CAAE,EAEvID,EAAUF,CACX,CACA,OAAOI,EAAe,CAAC,CAAE,EASzB,SAASA,EAAeC,EAAO,CAC9B,OAAOC,EASP,SAASA,EAASC,EAAI,CACrB,IAAIC,EAAQH,EAAK,MAAM,EAEvB,OADAG,EAAM,QAASD,CAAE,EACZC,EAAM,OAASL,EACZC,EAAeI,CAAM,EAEtBT,EAAI,MAAOG,EAASM,CAAM,CAClC,CACD,CACD,CAKAd,EAAO,QAAUI,ICrEjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isPositiveInteger", "format", "curryRight", "fcn", "arity", "thisArg", "context", "len", "createCurried", "args", "curried", "v", "cargs", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7271aed..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,53 +0,0 @@ - -{{alias}}( fcn[, arity][, thisArg] ) - Transforms a function into a sequence of functions each accepting a single - argument. - - Until return value resolution, each invocation returns a new partially - applied curry function. - - This function applies arguments starting from the right. - - Parameters - ---------- - fcn: Function - Function to curry. - - arity: integer (optional) - Number of parameters. Default: `fcn.length`. - - thisArg: any (optional) - Evaluation context. - - Returns - ------- - out: Function - Curry function. - - Examples - -------- - > function add( x, y ) { return x + y; }; - > var f = {{alias}}( add ); - > var sum = f( 2 )( 3 ) - 5 - - // Supply arity: - > function add() { return arguments[ 0 ] + arguments[ 1 ]; }; - > f = {{alias}}( add, 2 ); - > sum = f( 2 )( 3 ) - 5 - - // Provide function context: - > var obj = { - ... 'name': 'Ada', - ... 'greet': function greet( word1, word2 ) { - ... return word1 + ' ' + word2 + ', ' + this.name + '!' - ... } - ... }; - > f = {{alias}}( obj.greet, obj ); - > var str = f( 'there' )( 'Hello' ) - 'Hello there, Ada!' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4577cdb..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,71 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import curryRight = require( './index' ); - - -// TESTS // - -// The function returns a function... -{ - curryRight( ( x: number, y: number ): number => x + y ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: number, y: number ): number => x + y, 2 ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: number, y: number ): number => x + y, 2, {} ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: string, y: string ): string => x + y, {} ); // $ExpectType (v: string) => (v: string) => string - curryRight( ( x: string, y: string ): string => x + y, 2, {} ); // $ExpectType (v: string) => (v: string) => string - curryRight( ( str: string, n: number ): string => str.substring( n ) ); // $ExpectType (v: number) => (v: string) => string - - const cxt = { - 'count': 0, - 'multiply': function multiply( this: { count: number }, x: number, y: number ): number { - this.count += 1; // eslint-disable-line no-invalid-this - return x * y; - } - }; - curryRight( cxt.multiply ); // $ExpectType (v: number) => (v: number) => number - curryRight( cxt.multiply, 2 ); // $ExpectType (v: number) => (v: number) => number - curryRight( cxt.multiply, 2, { 'count': 2 } ); // $ExpectType (v: number) => (v: number) => number -} - -// The compiler throws an error if the function is provided a first argument other than a function... -{ - curryRight( true ); // $ExpectError - curryRight( false ); // $ExpectError - curryRight( 5 ); // $ExpectError - curryRight( [] ); // $ExpectError - curryRight( {} ); // $ExpectError - curryRight( 'abc' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a this argument which does not constitute a valid `this` context... -{ - const cxt = { - 'count': 0, - 'multiply': function multiply( this: { count: number }, x: number, y: number ): number { - this.count += 1; // eslint-disable-line no-invalid-this - return x * y; - } - }; - curryRight( cxt.multiply, { 'COUNT': 2 } ); // $ExpectError - curryRight( cxt.multiply, 2, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided more than three arguments... -{ - curryRight( ( x: number, y: number ): number => x + y, 2, {}, 4 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 76818ec..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 curryRight = require( './../lib' ); - -var fcn; -var out; -var i; - -function add( x, y, z, w, t, s ) { - return x + y + z + w + t + s; -} - -fcn = curryRight( add ); -out = fcn; -for ( i = 0; i < add.length; i++ ) { - out = out( i*10 ); -} -console.log( out ); 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..b4bb434 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@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 s(s,n,i){var o,l;if(!e(s))throw new TypeError(t("1SN3c",s));if(arguments.length<2){if(l=s.length,!r(l))throw new TypeError(t("1SNEX",l))}else if(arguments.length>2){if(o=i,!r(l=n))throw new TypeError(t("1SNAz",l))}else if(r(n))l=n;else{if(l=s.length,!r(l))throw new TypeError(t("1SNEX",l));o=n}return function e(r){return t;function t(t){var n=r.slice();return n.unshift(t),n.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNAz', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNEX', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","curried","v","cargs","slice","unshift","apply"],"mappings":";;kTAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,SAEjC,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAEjC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvCD,EAAUF,CACV,CACD,OASA,SAASU,EAAeC,GACvB,OAAOC,EASP,SAASA,EAASC,GACjB,IAAIC,EAAQH,EAAKI,QAEjB,OADAD,EAAME,QAASH,GACVC,EAAMN,OAASL,EACZO,EAAeI,GAEhBf,EAAIkB,MAAOf,EAASY,EAC3B,CACD,CA3BMJ,CAAe,GA4BvB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 7e7d2e8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform a function into a sequence of functions each accepting a single argument. -* -* @module @stdlib/utils-curry-right -* -* @example -* var curryRight = require( '@stdlib/utils-curry-right' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ - -// 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 ffb671a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* @param {Function} fcn - function to curry -* @param {PositiveInteger} [arity=fcn.length] - number of parameters -* @param {*} [thisArg] - evaluation context -* @throws {TypeError} first argument must be a function -* @throws {TypeError} first argument must be a function having at least one parameter -* @throws {TypeError} `arity` argument must be a positive integer -* @returns {Function} curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -function curryRight( fcn, arity, thisArg ) { - var context; - var len; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '1SN3c', fcn ) ); - } - if ( arguments.length < 2 ) { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNEX', len ) ); - } - } else if ( arguments.length > 2 ) { - len = arity; - context = thisArg; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNAz', len ) ); - } - } else if ( isPositiveInteger( arity ) ) { - len = arity; - } else { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNEX', len ) ); - } - context = arity; - } - return createCurried( [] ); - - /** - * Returns a curry function. - * - * @private - * @param {Array} args - arguments - * @returns {Function} curry function - */ - function createCurried( args ) { - return curried; - - /** - * Curry function. - * - * @private - * @param {*} v - curried function parameter - * @returns {(Function|*)} partially applied curry function or curried function result - */ - function curried( v ) { - var cargs = args.slice(); - cargs.unshift( v ); - if ( cargs.length < len ) { - return createCurried( cargs ); - } - return fcn.apply( context, cargs ); - } - } -} - - -// EXPORTS // - -module.exports = curryRight; diff --git a/package.json b/package.json index 07e31fc..f269d93 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Transform a function into a sequence of functions each accepting a single argument.", "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/assert-is-positive-integer": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/math-base-ops-add3": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.2.1", - "@stdlib/random-base-randu": "^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..5c63fa1 --- /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 3f1273f..0000000 --- a/test/test.js +++ /dev/null @@ -1,285 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var add = require( '@stdlib/math-base-ops-add3' ); -var curryRight = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof curryRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (1 arg)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (2 args; context)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an arity argument which is not a positive integer (3 args)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - 0, - -1, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( add, value, {} ); - }; - } -}); - -tape( 'the function returns a function', function test( t ) { - var fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function curries a function', function test( t) { - var fcn; - var f; - - fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'for each invocation where the invocation number is less than the arity, the curried function returns a new partially applied curry function', function test( t ) { - var sum; - var f0; - var f1; - var f2; - - // Initial curried function has no partially applied arguments... - f0 = curryRight( add ); - - sum = f0( 1 )( 2 )( 3 ); - t.strictEqual( sum, 6, 'returns 6' ); - - sum = f0( 1 )( 3 )( 5 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f0( 10 )( 20 )( 40 ); - t.strictEqual( sum, 70, 'returns 70' ); - - // If arity greater than 1, first invocation returns a curried function with one partially applied argument... - f1 = f0( 2 ); - - sum = f1( 3 )( 4 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f1( 10 )( 20 ); - t.strictEqual( sum, 32, 'returns 32' ); - - sum = f1( -1 )( -2 ); - t.strictEqual( sum, -1, 'returns -1' ); - - // If arity greater than 2, second invocation returns a curried function with two partially applied arguments... - f2 = f1( 3 ); - - sum = f2( 5 ); - t.strictEqual( sum, 10, 'returns 10' ); - - sum = f2( 6 ); - t.strictEqual( sum, 11, 'returns 11' ); - - sum = f2( 10 ); - t.strictEqual( sum, 15, 'returns 15' ); - - // And so on and so forth... - - t.end(); -}); - -tape( 'the function supports specifying a function arity', function test( t ) { - var fcn; - var f; - - function add() { - return arguments[ 0 ] + arguments[ 1 ] + arguments[ 2 ]; - } - - fcn = curryRight( add, 3 ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'the function supports specifying a function context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate( length, units, type, color ) { - return this.style+': '+length+units+' '+type+' '+color; - } - }; - - fcn = curryRight( context.generate, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); - -tape( 'the function supports specifying a function arity and context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate() { - return this.style+': '+arguments[0]+arguments[1]+' '+arguments[2]+' '+arguments[3]; - } - }; - - fcn = curryRight( context.generate, 4, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); From 6b81feeb6e6cf17599a8d8a6b2e0972d551508bd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 27 Jul 2024 18:34:44 +0000 Subject: [PATCH 107/140] 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 3591121..75a7ab6 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import curryRight from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-curry-right@esm/index.mjs'; +import curryRight from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-curry-right@v0.2.2-esm/index.mjs'; ``` #### curryRight( fcn\[, arity]\[, thisArg] ) @@ -192,7 +192,7 @@ var str = fcn( 'there' )( 'Hello' ); - - - - From b8e251e1c26efc1ee80709cf0a0ece734fcabe4c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 07:44:17 +0000 Subject: [PATCH 111/140] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 158 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 41 +- SECURITY.md | 5 - benchmark/benchmark.js | 90 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 53 - docs/types/test.ts | 71 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 110 - package.json | 57 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 285 -- 43 files changed, 4865 insertions(+), 4214 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 278075b..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-08-01T02:53:25.815Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2b7fad0..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/curry-right) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 9ffcfa1..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/curry-right) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 906f5af..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: '6 18 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -260,7 +251,7 @@ console.log( out ); ## 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]. @@ -325,11 +316,11 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry +[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry/tree/esm -[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry +[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry/tree/esm -[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right +[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right/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 69ca868..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isFunction = require( '@stdlib/assert-is-function' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var curryRight = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = curryRight( pow ); - if ( typeof out !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( out ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::returned_function', function benchmark( b ) { - var fcn; - var out; - var i; - - fcn = curryRight( pow ); - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = fcn( randu() )( randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::direct', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = pow( randu(), randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 7ef3db2..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/curry-right" -%% click B href "https://github.com/stdlib-js/utils-curry-right/tree/main" -%% click C href "https://github.com/stdlib-js/utils-curry-right/tree/production" -%% click D href "https://github.com/stdlib-js/utils-curry-right/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-curry-right/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-curry-right/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/curry-right -[production-url]: https://github.com/stdlib-js/utils-curry-right/tree/production -[deno-url]: https://github.com/stdlib-js/utils-curry-right/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-curry-right/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-curry-right/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-curry-right/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-curry-right/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-curry-right/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 8166962..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import curryRight from '../docs/types/index'; -export = curryRight; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 16477e0..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var g=f(function(b,o){ -var c=require('@stdlib/assert-is-function/dist'),n=require('@stdlib/assert-is-positive-integer/dist').isPrimitive,a=require('@stdlib/error-tools-fmtprodmsg/dist');function p(t,r,l){var u,e;if(!c(t))throw new TypeError(a('1SN3c',t));if(arguments.length<2){if(e=t.length,!n(e))throw new TypeError(a('1SNEX',e))}else if(arguments.length>2){if(e=r,u=l,!n(e))throw new TypeError(a('1SNAz',e))}else if(n(r))e=r;else{if(e=t.length,!n(e))throw new TypeError(a('1SNEX',e));u=r}return s([]);function s(m){return v;function v(h){var i=m.slice();return i.unshift(h),i.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = curryRight;\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* Transform a function into a sequence of functions each accepting a single argument.\n*\n* @module @stdlib/utils-curry-right\n*\n* @example\n* var curryRight = require( '@stdlib/utils-curry-right' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var f = curryRight( add );\n*\n* var sum = f( 2 )( 3 );\n* // returns 5\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,EAAoB,QAAS,oCAAqC,EAAE,YACpEC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,EAAYC,EAAKC,EAAOC,EAAU,CAC1C,IAAIC,EACAC,EACJ,GAAK,CAACR,EAAYI,CAAI,EACrB,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAI,CAAE,EAEzG,GAAK,UAAU,OAAS,GAEvB,GADAI,EAAMJ,EAAI,OACL,CAACH,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,kGAAmGM,CAAI,CAAE,UAE5H,UAAU,OAAS,GAG9B,GAFAA,EAAMH,EACNE,EAAUD,EACL,CAACL,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,4EAA6EM,CAAI,CAAE,UAEtGP,EAAmBI,CAAM,EACpCG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAI,OACL,CAACH,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,kGAAmGM,CAAI,CAAE,EAEvID,EAAUF,CACX,CACA,OAAOI,EAAe,CAAC,CAAE,EASzB,SAASA,EAAeC,EAAO,CAC9B,OAAOC,EASP,SAASA,EAASC,EAAI,CACrB,IAAIC,EAAQH,EAAK,MAAM,EAEvB,OADAG,EAAM,QAASD,CAAE,EACZC,EAAM,OAASL,EACZC,EAAeI,CAAM,EAEtBT,EAAI,MAAOG,EAASM,CAAM,CAClC,CACD,CACD,CAKAd,EAAO,QAAUI,ICrEjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isPositiveInteger", "format", "curryRight", "fcn", "arity", "thisArg", "context", "len", "createCurried", "args", "curried", "v", "cargs", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7271aed..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,53 +0,0 @@ - -{{alias}}( fcn[, arity][, thisArg] ) - Transforms a function into a sequence of functions each accepting a single - argument. - - Until return value resolution, each invocation returns a new partially - applied curry function. - - This function applies arguments starting from the right. - - Parameters - ---------- - fcn: Function - Function to curry. - - arity: integer (optional) - Number of parameters. Default: `fcn.length`. - - thisArg: any (optional) - Evaluation context. - - Returns - ------- - out: Function - Curry function. - - Examples - -------- - > function add( x, y ) { return x + y; }; - > var f = {{alias}}( add ); - > var sum = f( 2 )( 3 ) - 5 - - // Supply arity: - > function add() { return arguments[ 0 ] + arguments[ 1 ]; }; - > f = {{alias}}( add, 2 ); - > sum = f( 2 )( 3 ) - 5 - - // Provide function context: - > var obj = { - ... 'name': 'Ada', - ... 'greet': function greet( word1, word2 ) { - ... return word1 + ' ' + word2 + ', ' + this.name + '!' - ... } - ... }; - > f = {{alias}}( obj.greet, obj ); - > var str = f( 'there' )( 'Hello' ) - 'Hello there, Ada!' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4577cdb..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,71 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import curryRight = require( './index' ); - - -// TESTS // - -// The function returns a function... -{ - curryRight( ( x: number, y: number ): number => x + y ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: number, y: number ): number => x + y, 2 ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: number, y: number ): number => x + y, 2, {} ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: string, y: string ): string => x + y, {} ); // $ExpectType (v: string) => (v: string) => string - curryRight( ( x: string, y: string ): string => x + y, 2, {} ); // $ExpectType (v: string) => (v: string) => string - curryRight( ( str: string, n: number ): string => str.substring( n ) ); // $ExpectType (v: number) => (v: string) => string - - const cxt = { - 'count': 0, - 'multiply': function multiply( this: { count: number }, x: number, y: number ): number { - this.count += 1; // eslint-disable-line no-invalid-this - return x * y; - } - }; - curryRight( cxt.multiply ); // $ExpectType (v: number) => (v: number) => number - curryRight( cxt.multiply, 2 ); // $ExpectType (v: number) => (v: number) => number - curryRight( cxt.multiply, 2, { 'count': 2 } ); // $ExpectType (v: number) => (v: number) => number -} - -// The compiler throws an error if the function is provided a first argument other than a function... -{ - curryRight( true ); // $ExpectError - curryRight( false ); // $ExpectError - curryRight( 5 ); // $ExpectError - curryRight( [] ); // $ExpectError - curryRight( {} ); // $ExpectError - curryRight( 'abc' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a this argument which does not constitute a valid `this` context... -{ - const cxt = { - 'count': 0, - 'multiply': function multiply( this: { count: number }, x: number, y: number ): number { - this.count += 1; // eslint-disable-line no-invalid-this - return x * y; - } - }; - curryRight( cxt.multiply, { 'COUNT': 2 } ); // $ExpectError - curryRight( cxt.multiply, 2, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided more than three arguments... -{ - curryRight( ( x: number, y: number ): number => x + y, 2, {}, 4 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 76818ec..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 curryRight = require( './../lib' ); - -var fcn; -var out; -var i; - -function add( x, y, z, w, t, s ) { - return x + y + z + w + t + s; -} - -fcn = curryRight( add ); -out = fcn; -for ( i = 0; i < add.length; i++ ) { - out = out( i*10 ); -} -console.log( out ); 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..b4bb434 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@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 s(s,n,i){var o,l;if(!e(s))throw new TypeError(t("1SN3c",s));if(arguments.length<2){if(l=s.length,!r(l))throw new TypeError(t("1SNEX",l))}else if(arguments.length>2){if(o=i,!r(l=n))throw new TypeError(t("1SNAz",l))}else if(r(n))l=n;else{if(l=s.length,!r(l))throw new TypeError(t("1SNEX",l));o=n}return function e(r){return t;function t(t){var n=r.slice();return n.unshift(t),n.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNAz', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNEX', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","curried","v","cargs","slice","unshift","apply"],"mappings":";;kTAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,SAEjC,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAEjC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvCD,EAAUF,CACV,CACD,OASA,SAASU,EAAeC,GACvB,OAAOC,EASP,SAASA,EAASC,GACjB,IAAIC,EAAQH,EAAKI,QAEjB,OADAD,EAAME,QAASH,GACVC,EAAMN,OAASL,EACZO,EAAeI,GAEhBf,EAAIkB,MAAOf,EAASY,EAC3B,CACD,CA3BMJ,CAAe,GA4BvB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 7e7d2e8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform a function into a sequence of functions each accepting a single argument. -* -* @module @stdlib/utils-curry-right -* -* @example -* var curryRight = require( '@stdlib/utils-curry-right' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ - -// 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 ffb671a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* @param {Function} fcn - function to curry -* @param {PositiveInteger} [arity=fcn.length] - number of parameters -* @param {*} [thisArg] - evaluation context -* @throws {TypeError} first argument must be a function -* @throws {TypeError} first argument must be a function having at least one parameter -* @throws {TypeError} `arity` argument must be a positive integer -* @returns {Function} curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -function curryRight( fcn, arity, thisArg ) { - var context; - var len; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '1SN3c', fcn ) ); - } - if ( arguments.length < 2 ) { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNEX', len ) ); - } - } else if ( arguments.length > 2 ) { - len = arity; - context = thisArg; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNAz', len ) ); - } - } else if ( isPositiveInteger( arity ) ) { - len = arity; - } else { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNEX', len ) ); - } - context = arity; - } - return createCurried( [] ); - - /** - * Returns a curry function. - * - * @private - * @param {Array} args - arguments - * @returns {Function} curry function - */ - function createCurried( args ) { - return curried; - - /** - * Curry function. - * - * @private - * @param {*} v - curried function parameter - * @returns {(Function|*)} partially applied curry function or curried function result - */ - function curried( v ) { - var cargs = args.slice(); - cargs.unshift( v ); - if ( cargs.length < len ) { - return createCurried( cargs ); - } - return fcn.apply( context, cargs ); - } - } -} - - -// EXPORTS // - -module.exports = curryRight; diff --git a/package.json b/package.json index 5e700a4..f269d93 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Transform a function into a sequence of functions each accepting a single argument.", "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/assert-is-positive-integer": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/math-base-ops-add3": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/random-base-randu": "^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.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..5c63fa1 --- /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 3f1273f..0000000 --- a/test/test.js +++ /dev/null @@ -1,285 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var add = require( '@stdlib/math-base-ops-add3' ); -var curryRight = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof curryRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (1 arg)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (2 args; context)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an arity argument which is not a positive integer (3 args)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - 0, - -1, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( add, value, {} ); - }; - } -}); - -tape( 'the function returns a function', function test( t ) { - var fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function curries a function', function test( t) { - var fcn; - var f; - - fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'for each invocation where the invocation number is less than the arity, the curried function returns a new partially applied curry function', function test( t ) { - var sum; - var f0; - var f1; - var f2; - - // Initial curried function has no partially applied arguments... - f0 = curryRight( add ); - - sum = f0( 1 )( 2 )( 3 ); - t.strictEqual( sum, 6, 'returns 6' ); - - sum = f0( 1 )( 3 )( 5 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f0( 10 )( 20 )( 40 ); - t.strictEqual( sum, 70, 'returns 70' ); - - // If arity greater than 1, first invocation returns a curried function with one partially applied argument... - f1 = f0( 2 ); - - sum = f1( 3 )( 4 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f1( 10 )( 20 ); - t.strictEqual( sum, 32, 'returns 32' ); - - sum = f1( -1 )( -2 ); - t.strictEqual( sum, -1, 'returns -1' ); - - // If arity greater than 2, second invocation returns a curried function with two partially applied arguments... - f2 = f1( 3 ); - - sum = f2( 5 ); - t.strictEqual( sum, 10, 'returns 10' ); - - sum = f2( 6 ); - t.strictEqual( sum, 11, 'returns 11' ); - - sum = f2( 10 ); - t.strictEqual( sum, 15, 'returns 15' ); - - // And so on and so forth... - - t.end(); -}); - -tape( 'the function supports specifying a function arity', function test( t ) { - var fcn; - var f; - - function add() { - return arguments[ 0 ] + arguments[ 1 ] + arguments[ 2 ]; - } - - fcn = curryRight( add, 3 ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'the function supports specifying a function context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate( length, units, type, color ) { - return this.style+': '+length+units+' '+type+' '+color; - } - }; - - fcn = curryRight( context.generate, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); - -tape( 'the function supports specifying a function arity and context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate() { - return this.style+': '+arguments[0]+arguments[1]+' '+arguments[2]+' '+arguments[3]; - } - }; - - fcn = curryRight( context.generate, 4, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); From c289be1124a5ac81b287a9ce5e41074c2dfc5d55 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Aug 2024 18:50:43 +0000 Subject: [PATCH 112/140] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index 8d7768e..ffb671a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -52,25 +52,25 @@ function curryRight( fcn, arity, thisArg ) { var context; var len; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '1SN3c', fcn ) ); } if ( arguments.length < 2 ) { len = fcn.length; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); + throw new TypeError( format( '1SNEX', len ) ); } } else if ( arguments.length > 2 ) { len = arity; context = thisArg; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) ); + throw new TypeError( format( '1SNAz', len ) ); } } else if ( isPositiveInteger( arity ) ) { len = arity; } else { len = fcn.length; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); + throw new TypeError( format( '1SNEX', len ) ); } context = arity; } diff --git a/package.json b/package.json index d433a32..5e700a4 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-function": "^0.2.2", "@stdlib/assert-is-positive-integer": "^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 588917a92885318caadb52768a537c3c524f43ec Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Aug 2024 21:36:15 +0000 Subject: [PATCH 113/140] Remove files --- index.d.ts | 116 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4963 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 a4e85ef..0000000 --- a/index.d.ts +++ /dev/null @@ -1,116 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Utility type to reverse a tuple type. -*/ -type ReverseTuple> = T extends [infer First, ...infer Rest] ? [...ReverseTuple, First] : []; // eslint-disable-line @typescript-eslint/no-explicit-any - -/** - * Curry function type for curryRight. - */ -type CurryRightFunction< - TThis, - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn -> = ( this: TThis, ...args: TArgs ) => TReturn; - -/** -* Curry function. -* -* @param v - curried function parameter -* @returns partially applied curry function or curried function result -*/ -type Closure< - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn -> = ReverseTuple extends [infer TFirst, ...infer TRest] - ? ( v: TFirst ) => Closure, TReturn> - : TReturn; - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param arity - number of parameters -* @param thisArg - evaluation context -* @throws `arity` must be a positive integer -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight< - TThis extends object, - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn ->( - fcn: CurryRightFunction, - arity: number, - thisArg?: TThis -): Closure; - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param thisArg - evaluation context -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight< - TThis extends object, - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn ->( - fcn: CurryRightFunction, - thisArg?: TThis -): Closure; - - -// EXPORTS // - -export = curryRight; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b4bb434..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@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 s(s,n,i){var o,l;if(!e(s))throw new TypeError(t("1SN3c",s));if(arguments.length<2){if(l=s.length,!r(l))throw new TypeError(t("1SNEX",l))}else if(arguments.length>2){if(o=i,!r(l=n))throw new TypeError(t("1SNAz",l))}else if(r(n))l=n;else{if(l=s.length,!r(l))throw new TypeError(t("1SNEX",l));o=n}return function e(r){return t;function t(t){var n=r.slice();return n.unshift(t),n.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNAz', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNEX', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","curried","v","cargs","slice","unshift","apply"],"mappings":";;kTAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,SAEjC,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAEjC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvCD,EAAUF,CACV,CACD,OASA,SAASU,EAAeC,GACvB,OAAOC,EASP,SAASA,EAASC,GACjB,IAAIC,EAAQH,EAAKI,QAEjB,OADAD,EAAME,QAASH,GACVC,EAAMN,OAASL,EACZO,EAAeI,GAEhBf,EAAIkB,MAAOf,EAASY,EAC3B,CACD,CA3BMJ,CAAe,GA4BvB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 5c63fa1..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From da80cdcaf4c2b4213c6a372398bd1c196e5da253 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Aug 2024 21:36:30 +0000 Subject: [PATCH 114/140] 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 | 209 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 41 +- SECURITY.md | 5 - benchmark/benchmark.js | 90 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 53 - docs/types/test.ts | 71 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 110 - package.json | 57 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 285 -- 43 files changed, 4865 insertions(+), 4265 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 63f8623..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-08-03T17:57:22.212Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2b7fad0..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/curry-right) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 9ffcfa1..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/curry-right) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 906f5af..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: '6 18 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -260,7 +251,7 @@ console.log( out ); ## 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]. @@ -325,11 +316,11 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry +[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry/tree/esm -[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry +[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry/tree/esm -[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right +[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right/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 69ca868..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isFunction = require( '@stdlib/assert-is-function' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var curryRight = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = curryRight( pow ); - if ( typeof out !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( out ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::returned_function', function benchmark( b ) { - var fcn; - var out; - var i; - - fcn = curryRight( pow ); - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = fcn( randu() )( randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::direct', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = pow( randu(), randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 7ef3db2..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/curry-right" -%% click B href "https://github.com/stdlib-js/utils-curry-right/tree/main" -%% click C href "https://github.com/stdlib-js/utils-curry-right/tree/production" -%% click D href "https://github.com/stdlib-js/utils-curry-right/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-curry-right/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-curry-right/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/curry-right -[production-url]: https://github.com/stdlib-js/utils-curry-right/tree/production -[deno-url]: https://github.com/stdlib-js/utils-curry-right/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-curry-right/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-curry-right/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-curry-right/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-curry-right/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-curry-right/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 8166962..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import curryRight from '../docs/types/index'; -export = curryRight; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 16477e0..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var g=f(function(b,o){ -var c=require('@stdlib/assert-is-function/dist'),n=require('@stdlib/assert-is-positive-integer/dist').isPrimitive,a=require('@stdlib/error-tools-fmtprodmsg/dist');function p(t,r,l){var u,e;if(!c(t))throw new TypeError(a('1SN3c',t));if(arguments.length<2){if(e=t.length,!n(e))throw new TypeError(a('1SNEX',e))}else if(arguments.length>2){if(e=r,u=l,!n(e))throw new TypeError(a('1SNAz',e))}else if(n(r))e=r;else{if(e=t.length,!n(e))throw new TypeError(a('1SNEX',e));u=r}return s([]);function s(m){return v;function v(h){var i=m.slice();return i.unshift(h),i.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = curryRight;\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* Transform a function into a sequence of functions each accepting a single argument.\n*\n* @module @stdlib/utils-curry-right\n*\n* @example\n* var curryRight = require( '@stdlib/utils-curry-right' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var f = curryRight( add );\n*\n* var sum = f( 2 )( 3 );\n* // returns 5\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,EAAoB,QAAS,oCAAqC,EAAE,YACpEC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,EAAYC,EAAKC,EAAOC,EAAU,CAC1C,IAAIC,EACAC,EACJ,GAAK,CAACR,EAAYI,CAAI,EACrB,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAI,CAAE,EAEzG,GAAK,UAAU,OAAS,GAEvB,GADAI,EAAMJ,EAAI,OACL,CAACH,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,kGAAmGM,CAAI,CAAE,UAE5H,UAAU,OAAS,GAG9B,GAFAA,EAAMH,EACNE,EAAUD,EACL,CAACL,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,4EAA6EM,CAAI,CAAE,UAEtGP,EAAmBI,CAAM,EACpCG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAI,OACL,CAACH,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,kGAAmGM,CAAI,CAAE,EAEvID,EAAUF,CACX,CACA,OAAOI,EAAe,CAAC,CAAE,EASzB,SAASA,EAAeC,EAAO,CAC9B,OAAOC,EASP,SAASA,EAASC,EAAI,CACrB,IAAIC,EAAQH,EAAK,MAAM,EAEvB,OADAG,EAAM,QAASD,CAAE,EACZC,EAAM,OAASL,EACZC,EAAeI,CAAM,EAEtBT,EAAI,MAAOG,EAASM,CAAM,CAClC,CACD,CACD,CAKAd,EAAO,QAAUI,ICrEjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isPositiveInteger", "format", "curryRight", "fcn", "arity", "thisArg", "context", "len", "createCurried", "args", "curried", "v", "cargs", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7271aed..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,53 +0,0 @@ - -{{alias}}( fcn[, arity][, thisArg] ) - Transforms a function into a sequence of functions each accepting a single - argument. - - Until return value resolution, each invocation returns a new partially - applied curry function. - - This function applies arguments starting from the right. - - Parameters - ---------- - fcn: Function - Function to curry. - - arity: integer (optional) - Number of parameters. Default: `fcn.length`. - - thisArg: any (optional) - Evaluation context. - - Returns - ------- - out: Function - Curry function. - - Examples - -------- - > function add( x, y ) { return x + y; }; - > var f = {{alias}}( add ); - > var sum = f( 2 )( 3 ) - 5 - - // Supply arity: - > function add() { return arguments[ 0 ] + arguments[ 1 ]; }; - > f = {{alias}}( add, 2 ); - > sum = f( 2 )( 3 ) - 5 - - // Provide function context: - > var obj = { - ... 'name': 'Ada', - ... 'greet': function greet( word1, word2 ) { - ... return word1 + ' ' + word2 + ', ' + this.name + '!' - ... } - ... }; - > f = {{alias}}( obj.greet, obj ); - > var str = f( 'there' )( 'Hello' ) - 'Hello there, Ada!' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4577cdb..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,71 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import curryRight = require( './index' ); - - -// TESTS // - -// The function returns a function... -{ - curryRight( ( x: number, y: number ): number => x + y ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: number, y: number ): number => x + y, 2 ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: number, y: number ): number => x + y, 2, {} ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: string, y: string ): string => x + y, {} ); // $ExpectType (v: string) => (v: string) => string - curryRight( ( x: string, y: string ): string => x + y, 2, {} ); // $ExpectType (v: string) => (v: string) => string - curryRight( ( str: string, n: number ): string => str.substring( n ) ); // $ExpectType (v: number) => (v: string) => string - - const cxt = { - 'count': 0, - 'multiply': function multiply( this: { count: number }, x: number, y: number ): number { - this.count += 1; // eslint-disable-line no-invalid-this - return x * y; - } - }; - curryRight( cxt.multiply ); // $ExpectType (v: number) => (v: number) => number - curryRight( cxt.multiply, 2 ); // $ExpectType (v: number) => (v: number) => number - curryRight( cxt.multiply, 2, { 'count': 2 } ); // $ExpectType (v: number) => (v: number) => number -} - -// The compiler throws an error if the function is provided a first argument other than a function... -{ - curryRight( true ); // $ExpectError - curryRight( false ); // $ExpectError - curryRight( 5 ); // $ExpectError - curryRight( [] ); // $ExpectError - curryRight( {} ); // $ExpectError - curryRight( 'abc' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a this argument which does not constitute a valid `this` context... -{ - const cxt = { - 'count': 0, - 'multiply': function multiply( this: { count: number }, x: number, y: number ): number { - this.count += 1; // eslint-disable-line no-invalid-this - return x * y; - } - }; - curryRight( cxt.multiply, { 'COUNT': 2 } ); // $ExpectError - curryRight( cxt.multiply, 2, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided more than three arguments... -{ - curryRight( ( x: number, y: number ): number => x + y, 2, {}, 4 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 76818ec..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 curryRight = require( './../lib' ); - -var fcn; -var out; -var i; - -function add( x, y, z, w, t, s ) { - return x + y + z + w + t + s; -} - -fcn = curryRight( add ); -out = fcn; -for ( i = 0; i < add.length; i++ ) { - out = out( i*10 ); -} -console.log( out ); 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..b4bb434 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@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 s(s,n,i){var o,l;if(!e(s))throw new TypeError(t("1SN3c",s));if(arguments.length<2){if(l=s.length,!r(l))throw new TypeError(t("1SNEX",l))}else if(arguments.length>2){if(o=i,!r(l=n))throw new TypeError(t("1SNAz",l))}else if(r(n))l=n;else{if(l=s.length,!r(l))throw new TypeError(t("1SNEX",l));o=n}return function e(r){return t;function t(t){var n=r.slice();return n.unshift(t),n.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNAz', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNEX', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","curried","v","cargs","slice","unshift","apply"],"mappings":";;kTAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,SAEjC,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAEjC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvCD,EAAUF,CACV,CACD,OASA,SAASU,EAAeC,GACvB,OAAOC,EASP,SAASA,EAASC,GACjB,IAAIC,EAAQH,EAAKI,QAEjB,OADAD,EAAME,QAASH,GACVC,EAAMN,OAASL,EACZO,EAAeI,GAEhBf,EAAIkB,MAAOf,EAASY,EAC3B,CACD,CA3BMJ,CAAe,GA4BvB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 7e7d2e8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform a function into a sequence of functions each accepting a single argument. -* -* @module @stdlib/utils-curry-right -* -* @example -* var curryRight = require( '@stdlib/utils-curry-right' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ - -// 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 ffb671a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* @param {Function} fcn - function to curry -* @param {PositiveInteger} [arity=fcn.length] - number of parameters -* @param {*} [thisArg] - evaluation context -* @throws {TypeError} first argument must be a function -* @throws {TypeError} first argument must be a function having at least one parameter -* @throws {TypeError} `arity` argument must be a positive integer -* @returns {Function} curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -function curryRight( fcn, arity, thisArg ) { - var context; - var len; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '1SN3c', fcn ) ); - } - if ( arguments.length < 2 ) { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNEX', len ) ); - } - } else if ( arguments.length > 2 ) { - len = arity; - context = thisArg; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNAz', len ) ); - } - } else if ( isPositiveInteger( arity ) ) { - len = arity; - } else { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNEX', len ) ); - } - context = arity; - } - return createCurried( [] ); - - /** - * Returns a curry function. - * - * @private - * @param {Array} args - arguments - * @returns {Function} curry function - */ - function createCurried( args ) { - return curried; - - /** - * Curry function. - * - * @private - * @param {*} v - curried function parameter - * @returns {(Function|*)} partially applied curry function or curried function result - */ - function curried( v ) { - var cargs = args.slice(); - cargs.unshift( v ); - if ( cargs.length < len ) { - return createCurried( cargs ); - } - return fcn.apply( context, cargs ); - } - } -} - - -// EXPORTS // - -module.exports = curryRight; diff --git a/package.json b/package.json index 5e700a4..f269d93 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Transform a function into a sequence of functions each accepting a single argument.", "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/assert-is-positive-integer": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/math-base-ops-add3": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/random-base-randu": "^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.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..5c63fa1 --- /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 3f1273f..0000000 --- a/test/test.js +++ /dev/null @@ -1,285 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var add = require( '@stdlib/math-base-ops-add3' ); -var curryRight = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof curryRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (1 arg)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (2 args; context)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an arity argument which is not a positive integer (3 args)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - 0, - -1, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( add, value, {} ); - }; - } -}); - -tape( 'the function returns a function', function test( t ) { - var fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function curries a function', function test( t) { - var fcn; - var f; - - fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'for each invocation where the invocation number is less than the arity, the curried function returns a new partially applied curry function', function test( t ) { - var sum; - var f0; - var f1; - var f2; - - // Initial curried function has no partially applied arguments... - f0 = curryRight( add ); - - sum = f0( 1 )( 2 )( 3 ); - t.strictEqual( sum, 6, 'returns 6' ); - - sum = f0( 1 )( 3 )( 5 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f0( 10 )( 20 )( 40 ); - t.strictEqual( sum, 70, 'returns 70' ); - - // If arity greater than 1, first invocation returns a curried function with one partially applied argument... - f1 = f0( 2 ); - - sum = f1( 3 )( 4 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f1( 10 )( 20 ); - t.strictEqual( sum, 32, 'returns 32' ); - - sum = f1( -1 )( -2 ); - t.strictEqual( sum, -1, 'returns -1' ); - - // If arity greater than 2, second invocation returns a curried function with two partially applied arguments... - f2 = f1( 3 ); - - sum = f2( 5 ); - t.strictEqual( sum, 10, 'returns 10' ); - - sum = f2( 6 ); - t.strictEqual( sum, 11, 'returns 11' ); - - sum = f2( 10 ); - t.strictEqual( sum, 15, 'returns 15' ); - - // And so on and so forth... - - t.end(); -}); - -tape( 'the function supports specifying a function arity', function test( t ) { - var fcn; - var f; - - function add() { - return arguments[ 0 ] + arguments[ 1 ] + arguments[ 2 ]; - } - - fcn = curryRight( add, 3 ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'the function supports specifying a function context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate( length, units, type, color ) { - return this.style+': '+length+units+' '+type+' '+color; - } - }; - - fcn = curryRight( context.generate, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); - -tape( 'the function supports specifying a function arity and context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate() { - return this.style+': '+arguments[0]+arguments[1]+' '+arguments[2]+' '+arguments[3]; - } - }; - - fcn = curryRight( context.generate, 4, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); From 1b13dafc69969d646d18e462f0e2940373ee74f1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 04:11:18 +0000 Subject: [PATCH 115/140] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index 8d7768e..ffb671a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -52,25 +52,25 @@ function curryRight( fcn, arity, thisArg ) { var context; var len; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '1SN3c', fcn ) ); } if ( arguments.length < 2 ) { len = fcn.length; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); + throw new TypeError( format( '1SNEX', len ) ); } } else if ( arguments.length > 2 ) { len = arity; context = thisArg; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) ); + throw new TypeError( format( '1SNAz', len ) ); } } else if ( isPositiveInteger( arity ) ) { len = arity; } else { len = fcn.length; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); + throw new TypeError( format( '1SNEX', len ) ); } context = arity; } diff --git a/package.json b/package.json index d433a32..5e700a4 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-function": "^0.2.2", "@stdlib/assert-is-positive-integer": "^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 4b1285459482be990912bb166d435ec8f24ed265 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 07:37:32 +0000 Subject: [PATCH 116/140] Remove files --- index.d.ts | 116 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4963 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 a4e85ef..0000000 --- a/index.d.ts +++ /dev/null @@ -1,116 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Utility type to reverse a tuple type. -*/ -type ReverseTuple> = T extends [infer First, ...infer Rest] ? [...ReverseTuple, First] : []; // eslint-disable-line @typescript-eslint/no-explicit-any - -/** - * Curry function type for curryRight. - */ -type CurryRightFunction< - TThis, - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn -> = ( this: TThis, ...args: TArgs ) => TReturn; - -/** -* Curry function. -* -* @param v - curried function parameter -* @returns partially applied curry function or curried function result -*/ -type Closure< - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn -> = ReverseTuple extends [infer TFirst, ...infer TRest] - ? ( v: TFirst ) => Closure, TReturn> - : TReturn; - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param arity - number of parameters -* @param thisArg - evaluation context -* @throws `arity` must be a positive integer -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight< - TThis extends object, - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn ->( - fcn: CurryRightFunction, - arity: number, - thisArg?: TThis -): Closure; - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param thisArg - evaluation context -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight< - TThis extends object, - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn ->( - fcn: CurryRightFunction, - thisArg?: TThis -): Closure; - - -// EXPORTS // - -export = curryRight; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b4bb434..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@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 s(s,n,i){var o,l;if(!e(s))throw new TypeError(t("1SN3c",s));if(arguments.length<2){if(l=s.length,!r(l))throw new TypeError(t("1SNEX",l))}else if(arguments.length>2){if(o=i,!r(l=n))throw new TypeError(t("1SNAz",l))}else if(r(n))l=n;else{if(l=s.length,!r(l))throw new TypeError(t("1SNEX",l));o=n}return function e(r){return t;function t(t){var n=r.slice();return n.unshift(t),n.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNAz', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNEX', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","curried","v","cargs","slice","unshift","apply"],"mappings":";;kTAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,SAEjC,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAEjC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvCD,EAAUF,CACV,CACD,OASA,SAASU,EAAeC,GACvB,OAAOC,EASP,SAASA,EAASC,GACjB,IAAIC,EAAQH,EAAKI,QAEjB,OADAD,EAAME,QAASH,GACVC,EAAMN,OAASL,EACZO,EAAeI,GAEhBf,EAAIkB,MAAOf,EAASY,EAC3B,CACD,CA3BMJ,CAAe,GA4BvB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 5c63fa1..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 904cdd923616b7f571f997cf2bb65900fa40b31b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 07:37:46 +0000 Subject: [PATCH 117/140] 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 | 208 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 41 +- SECURITY.md | 5 - benchmark/benchmark.js | 90 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 53 - docs/types/test.ts | 71 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 110 - package.json | 57 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 285 -- 43 files changed, 4865 insertions(+), 4264 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 1dd22c6..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-09-01T03:04:15.930Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2b7fad0..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/curry-right) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 9ffcfa1..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/curry-right) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 906f5af..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: '6 18 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -260,7 +251,7 @@ console.log( out ); ## 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]. @@ -325,11 +316,11 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry +[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry/tree/esm -[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry +[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry/tree/esm -[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right +[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right/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 69ca868..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isFunction = require( '@stdlib/assert-is-function' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var curryRight = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = curryRight( pow ); - if ( typeof out !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( out ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::returned_function', function benchmark( b ) { - var fcn; - var out; - var i; - - fcn = curryRight( pow ); - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = fcn( randu() )( randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::direct', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = pow( randu(), randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 7ef3db2..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/curry-right" -%% click B href "https://github.com/stdlib-js/utils-curry-right/tree/main" -%% click C href "https://github.com/stdlib-js/utils-curry-right/tree/production" -%% click D href "https://github.com/stdlib-js/utils-curry-right/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-curry-right/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-curry-right/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/curry-right -[production-url]: https://github.com/stdlib-js/utils-curry-right/tree/production -[deno-url]: https://github.com/stdlib-js/utils-curry-right/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-curry-right/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-curry-right/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-curry-right/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-curry-right/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-curry-right/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 8166962..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import curryRight from '../docs/types/index'; -export = curryRight; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 16477e0..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var g=f(function(b,o){ -var c=require('@stdlib/assert-is-function/dist'),n=require('@stdlib/assert-is-positive-integer/dist').isPrimitive,a=require('@stdlib/error-tools-fmtprodmsg/dist');function p(t,r,l){var u,e;if(!c(t))throw new TypeError(a('1SN3c',t));if(arguments.length<2){if(e=t.length,!n(e))throw new TypeError(a('1SNEX',e))}else if(arguments.length>2){if(e=r,u=l,!n(e))throw new TypeError(a('1SNAz',e))}else if(n(r))e=r;else{if(e=t.length,!n(e))throw new TypeError(a('1SNEX',e));u=r}return s([]);function s(m){return v;function v(h){var i=m.slice();return i.unshift(h),i.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = curryRight;\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* Transform a function into a sequence of functions each accepting a single argument.\n*\n* @module @stdlib/utils-curry-right\n*\n* @example\n* var curryRight = require( '@stdlib/utils-curry-right' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var f = curryRight( add );\n*\n* var sum = f( 2 )( 3 );\n* // returns 5\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,EAAoB,QAAS,oCAAqC,EAAE,YACpEC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,EAAYC,EAAKC,EAAOC,EAAU,CAC1C,IAAIC,EACAC,EACJ,GAAK,CAACR,EAAYI,CAAI,EACrB,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAI,CAAE,EAEzG,GAAK,UAAU,OAAS,GAEvB,GADAI,EAAMJ,EAAI,OACL,CAACH,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,kGAAmGM,CAAI,CAAE,UAE5H,UAAU,OAAS,GAG9B,GAFAA,EAAMH,EACNE,EAAUD,EACL,CAACL,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,4EAA6EM,CAAI,CAAE,UAEtGP,EAAmBI,CAAM,EACpCG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAI,OACL,CAACH,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,kGAAmGM,CAAI,CAAE,EAEvID,EAAUF,CACX,CACA,OAAOI,EAAe,CAAC,CAAE,EASzB,SAASA,EAAeC,EAAO,CAC9B,OAAOC,EASP,SAASA,EAASC,EAAI,CACrB,IAAIC,EAAQH,EAAK,MAAM,EAEvB,OADAG,EAAM,QAASD,CAAE,EACZC,EAAM,OAASL,EACZC,EAAeI,CAAM,EAEtBT,EAAI,MAAOG,EAASM,CAAM,CAClC,CACD,CACD,CAKAd,EAAO,QAAUI,ICrEjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isPositiveInteger", "format", "curryRight", "fcn", "arity", "thisArg", "context", "len", "createCurried", "args", "curried", "v", "cargs", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7271aed..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,53 +0,0 @@ - -{{alias}}( fcn[, arity][, thisArg] ) - Transforms a function into a sequence of functions each accepting a single - argument. - - Until return value resolution, each invocation returns a new partially - applied curry function. - - This function applies arguments starting from the right. - - Parameters - ---------- - fcn: Function - Function to curry. - - arity: integer (optional) - Number of parameters. Default: `fcn.length`. - - thisArg: any (optional) - Evaluation context. - - Returns - ------- - out: Function - Curry function. - - Examples - -------- - > function add( x, y ) { return x + y; }; - > var f = {{alias}}( add ); - > var sum = f( 2 )( 3 ) - 5 - - // Supply arity: - > function add() { return arguments[ 0 ] + arguments[ 1 ]; }; - > f = {{alias}}( add, 2 ); - > sum = f( 2 )( 3 ) - 5 - - // Provide function context: - > var obj = { - ... 'name': 'Ada', - ... 'greet': function greet( word1, word2 ) { - ... return word1 + ' ' + word2 + ', ' + this.name + '!' - ... } - ... }; - > f = {{alias}}( obj.greet, obj ); - > var str = f( 'there' )( 'Hello' ) - 'Hello there, Ada!' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4577cdb..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,71 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import curryRight = require( './index' ); - - -// TESTS // - -// The function returns a function... -{ - curryRight( ( x: number, y: number ): number => x + y ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: number, y: number ): number => x + y, 2 ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: number, y: number ): number => x + y, 2, {} ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: string, y: string ): string => x + y, {} ); // $ExpectType (v: string) => (v: string) => string - curryRight( ( x: string, y: string ): string => x + y, 2, {} ); // $ExpectType (v: string) => (v: string) => string - curryRight( ( str: string, n: number ): string => str.substring( n ) ); // $ExpectType (v: number) => (v: string) => string - - const cxt = { - 'count': 0, - 'multiply': function multiply( this: { count: number }, x: number, y: number ): number { - this.count += 1; // eslint-disable-line no-invalid-this - return x * y; - } - }; - curryRight( cxt.multiply ); // $ExpectType (v: number) => (v: number) => number - curryRight( cxt.multiply, 2 ); // $ExpectType (v: number) => (v: number) => number - curryRight( cxt.multiply, 2, { 'count': 2 } ); // $ExpectType (v: number) => (v: number) => number -} - -// The compiler throws an error if the function is provided a first argument other than a function... -{ - curryRight( true ); // $ExpectError - curryRight( false ); // $ExpectError - curryRight( 5 ); // $ExpectError - curryRight( [] ); // $ExpectError - curryRight( {} ); // $ExpectError - curryRight( 'abc' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a this argument which does not constitute a valid `this` context... -{ - const cxt = { - 'count': 0, - 'multiply': function multiply( this: { count: number }, x: number, y: number ): number { - this.count += 1; // eslint-disable-line no-invalid-this - return x * y; - } - }; - curryRight( cxt.multiply, { 'COUNT': 2 } ); // $ExpectError - curryRight( cxt.multiply, 2, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided more than three arguments... -{ - curryRight( ( x: number, y: number ): number => x + y, 2, {}, 4 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 76818ec..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 curryRight = require( './../lib' ); - -var fcn; -var out; -var i; - -function add( x, y, z, w, t, s ) { - return x + y + z + w + t + s; -} - -fcn = curryRight( add ); -out = fcn; -for ( i = 0; i < add.length; i++ ) { - out = out( i*10 ); -} -console.log( out ); 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..b4bb434 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@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 s(s,n,i){var o,l;if(!e(s))throw new TypeError(t("1SN3c",s));if(arguments.length<2){if(l=s.length,!r(l))throw new TypeError(t("1SNEX",l))}else if(arguments.length>2){if(o=i,!r(l=n))throw new TypeError(t("1SNAz",l))}else if(r(n))l=n;else{if(l=s.length,!r(l))throw new TypeError(t("1SNEX",l));o=n}return function e(r){return t;function t(t){var n=r.slice();return n.unshift(t),n.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNAz', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNEX', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","curried","v","cargs","slice","unshift","apply"],"mappings":";;kTAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,SAEjC,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAEjC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvCD,EAAUF,CACV,CACD,OASA,SAASU,EAAeC,GACvB,OAAOC,EASP,SAASA,EAASC,GACjB,IAAIC,EAAQH,EAAKI,QAEjB,OADAD,EAAME,QAASH,GACVC,EAAMN,OAASL,EACZO,EAAeI,GAEhBf,EAAIkB,MAAOf,EAASY,EAC3B,CACD,CA3BMJ,CAAe,GA4BvB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 7e7d2e8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform a function into a sequence of functions each accepting a single argument. -* -* @module @stdlib/utils-curry-right -* -* @example -* var curryRight = require( '@stdlib/utils-curry-right' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ - -// 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 ffb671a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* @param {Function} fcn - function to curry -* @param {PositiveInteger} [arity=fcn.length] - number of parameters -* @param {*} [thisArg] - evaluation context -* @throws {TypeError} first argument must be a function -* @throws {TypeError} first argument must be a function having at least one parameter -* @throws {TypeError} `arity` argument must be a positive integer -* @returns {Function} curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -function curryRight( fcn, arity, thisArg ) { - var context; - var len; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '1SN3c', fcn ) ); - } - if ( arguments.length < 2 ) { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNEX', len ) ); - } - } else if ( arguments.length > 2 ) { - len = arity; - context = thisArg; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNAz', len ) ); - } - } else if ( isPositiveInteger( arity ) ) { - len = arity; - } else { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNEX', len ) ); - } - context = arity; - } - return createCurried( [] ); - - /** - * Returns a curry function. - * - * @private - * @param {Array} args - arguments - * @returns {Function} curry function - */ - function createCurried( args ) { - return curried; - - /** - * Curry function. - * - * @private - * @param {*} v - curried function parameter - * @returns {(Function|*)} partially applied curry function or curried function result - */ - function curried( v ) { - var cargs = args.slice(); - cargs.unshift( v ); - if ( cargs.length < len ) { - return createCurried( cargs ); - } - return fcn.apply( context, cargs ); - } - } -} - - -// EXPORTS // - -module.exports = curryRight; diff --git a/package.json b/package.json index 5e700a4..f269d93 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Transform a function into a sequence of functions each accepting a single argument.", "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/assert-is-positive-integer": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/math-base-ops-add3": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/random-base-randu": "^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.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..5c63fa1 --- /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 3f1273f..0000000 --- a/test/test.js +++ /dev/null @@ -1,285 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var add = require( '@stdlib/math-base-ops-add3' ); -var curryRight = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof curryRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (1 arg)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (2 args; context)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an arity argument which is not a positive integer (3 args)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - 0, - -1, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( add, value, {} ); - }; - } -}); - -tape( 'the function returns a function', function test( t ) { - var fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function curries a function', function test( t) { - var fcn; - var f; - - fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'for each invocation where the invocation number is less than the arity, the curried function returns a new partially applied curry function', function test( t ) { - var sum; - var f0; - var f1; - var f2; - - // Initial curried function has no partially applied arguments... - f0 = curryRight( add ); - - sum = f0( 1 )( 2 )( 3 ); - t.strictEqual( sum, 6, 'returns 6' ); - - sum = f0( 1 )( 3 )( 5 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f0( 10 )( 20 )( 40 ); - t.strictEqual( sum, 70, 'returns 70' ); - - // If arity greater than 1, first invocation returns a curried function with one partially applied argument... - f1 = f0( 2 ); - - sum = f1( 3 )( 4 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f1( 10 )( 20 ); - t.strictEqual( sum, 32, 'returns 32' ); - - sum = f1( -1 )( -2 ); - t.strictEqual( sum, -1, 'returns -1' ); - - // If arity greater than 2, second invocation returns a curried function with two partially applied arguments... - f2 = f1( 3 ); - - sum = f2( 5 ); - t.strictEqual( sum, 10, 'returns 10' ); - - sum = f2( 6 ); - t.strictEqual( sum, 11, 'returns 11' ); - - sum = f2( 10 ); - t.strictEqual( sum, 15, 'returns 15' ); - - // And so on and so forth... - - t.end(); -}); - -tape( 'the function supports specifying a function arity', function test( t ) { - var fcn; - var f; - - function add() { - return arguments[ 0 ] + arguments[ 1 ] + arguments[ 2 ]; - } - - fcn = curryRight( add, 3 ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'the function supports specifying a function context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate( length, units, type, color ) { - return this.style+': '+length+units+' '+type+' '+color; - } - }; - - fcn = curryRight( context.generate, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); - -tape( 'the function supports specifying a function arity and context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate() { - return this.style+': '+arguments[0]+arguments[1]+' '+arguments[2]+' '+arguments[3]; - } - }; - - fcn = curryRight( context.generate, 4, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); From 6f8ef5a715bac3658ace7c125916a38113ff95ba Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 28 Sep 2024 18:22:41 +0000 Subject: [PATCH 118/140] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index 8d7768e..ffb671a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -52,25 +52,25 @@ function curryRight( fcn, arity, thisArg ) { var context; var len; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '1SN3c', fcn ) ); } if ( arguments.length < 2 ) { len = fcn.length; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); + throw new TypeError( format( '1SNEX', len ) ); } } else if ( arguments.length > 2 ) { len = arity; context = thisArg; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) ); + throw new TypeError( format( '1SNAz', len ) ); } } else if ( isPositiveInteger( arity ) ) { len = arity; } else { len = fcn.length; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); + throw new TypeError( format( '1SNEX', len ) ); } context = arity; } diff --git a/package.json b/package.json index d433a32..5e700a4 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-function": "^0.2.2", "@stdlib/assert-is-positive-integer": "^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 30ee9ea0a54ee68ccc9fb7e2d08c2835094845c6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 28 Sep 2024 18:28:31 +0000 Subject: [PATCH 119/140] Remove files --- index.d.ts | 116 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4963 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 a4e85ef..0000000 --- a/index.d.ts +++ /dev/null @@ -1,116 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Utility type to reverse a tuple type. -*/ -type ReverseTuple> = T extends [infer First, ...infer Rest] ? [...ReverseTuple, First] : []; // eslint-disable-line @typescript-eslint/no-explicit-any - -/** - * Curry function type for curryRight. - */ -type CurryRightFunction< - TThis, - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn -> = ( this: TThis, ...args: TArgs ) => TReturn; - -/** -* Curry function. -* -* @param v - curried function parameter -* @returns partially applied curry function or curried function result -*/ -type Closure< - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn -> = ReverseTuple extends [infer TFirst, ...infer TRest] - ? ( v: TFirst ) => Closure, TReturn> - : TReturn; - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param arity - number of parameters -* @param thisArg - evaluation context -* @throws `arity` must be a positive integer -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight< - TThis extends object, - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn ->( - fcn: CurryRightFunction, - arity: number, - thisArg?: TThis -): Closure; - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param thisArg - evaluation context -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight< - TThis extends object, - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn ->( - fcn: CurryRightFunction, - thisArg?: TThis -): Closure; - - -// EXPORTS // - -export = curryRight; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b4bb434..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@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 s(s,n,i){var o,l;if(!e(s))throw new TypeError(t("1SN3c",s));if(arguments.length<2){if(l=s.length,!r(l))throw new TypeError(t("1SNEX",l))}else if(arguments.length>2){if(o=i,!r(l=n))throw new TypeError(t("1SNAz",l))}else if(r(n))l=n;else{if(l=s.length,!r(l))throw new TypeError(t("1SNEX",l));o=n}return function e(r){return t;function t(t){var n=r.slice();return n.unshift(t),n.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNAz', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNEX', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","curried","v","cargs","slice","unshift","apply"],"mappings":";;kTAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,SAEjC,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAEjC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvCD,EAAUF,CACV,CACD,OASA,SAASU,EAAeC,GACvB,OAAOC,EASP,SAASA,EAASC,GACjB,IAAIC,EAAQH,EAAKI,QAEjB,OADAD,EAAME,QAASH,GACVC,EAAMN,OAASL,EACZO,EAAeI,GAEhBf,EAAIkB,MAAOf,EAASY,EAC3B,CACD,CA3BMJ,CAAe,GA4BvB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 5c63fa1..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From c70fbb34450f758bec0c4bb8fe06b42526b071d8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 28 Sep 2024 18:28:51 +0000 Subject: [PATCH 120/140] 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 | 242 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 41 +- SECURITY.md | 5 - benchmark/benchmark.js | 90 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 53 - docs/types/test.ts | 71 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 110 - package.json | 57 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 285 -- 42 files changed, 4865 insertions(+), 4297 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 2b7fad0..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/curry-right) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 9ffcfa1..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/curry-right) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 906f5af..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: '6 18 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -260,7 +251,7 @@ console.log( out ); ## 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]. @@ -325,11 +316,11 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry +[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry/tree/esm -[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry +[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry/tree/esm -[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right +[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right/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 69ca868..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isFunction = require( '@stdlib/assert-is-function' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var curryRight = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = curryRight( pow ); - if ( typeof out !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( out ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::returned_function', function benchmark( b ) { - var fcn; - var out; - var i; - - fcn = curryRight( pow ); - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = fcn( randu() )( randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::direct', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = pow( randu(), randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 7ef3db2..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/curry-right" -%% click B href "https://github.com/stdlib-js/utils-curry-right/tree/main" -%% click C href "https://github.com/stdlib-js/utils-curry-right/tree/production" -%% click D href "https://github.com/stdlib-js/utils-curry-right/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-curry-right/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-curry-right/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/curry-right -[production-url]: https://github.com/stdlib-js/utils-curry-right/tree/production -[deno-url]: https://github.com/stdlib-js/utils-curry-right/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-curry-right/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-curry-right/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-curry-right/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-curry-right/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-curry-right/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 8166962..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import curryRight from '../docs/types/index'; -export = curryRight; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 16477e0..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var g=f(function(b,o){ -var c=require('@stdlib/assert-is-function/dist'),n=require('@stdlib/assert-is-positive-integer/dist').isPrimitive,a=require('@stdlib/error-tools-fmtprodmsg/dist');function p(t,r,l){var u,e;if(!c(t))throw new TypeError(a('1SN3c',t));if(arguments.length<2){if(e=t.length,!n(e))throw new TypeError(a('1SNEX',e))}else if(arguments.length>2){if(e=r,u=l,!n(e))throw new TypeError(a('1SNAz',e))}else if(n(r))e=r;else{if(e=t.length,!n(e))throw new TypeError(a('1SNEX',e));u=r}return s([]);function s(m){return v;function v(h){var i=m.slice();return i.unshift(h),i.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = curryRight;\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* Transform a function into a sequence of functions each accepting a single argument.\n*\n* @module @stdlib/utils-curry-right\n*\n* @example\n* var curryRight = require( '@stdlib/utils-curry-right' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var f = curryRight( add );\n*\n* var sum = f( 2 )( 3 );\n* // returns 5\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,EAAoB,QAAS,oCAAqC,EAAE,YACpEC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,EAAYC,EAAKC,EAAOC,EAAU,CAC1C,IAAIC,EACAC,EACJ,GAAK,CAACR,EAAYI,CAAI,EACrB,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAI,CAAE,EAEzG,GAAK,UAAU,OAAS,GAEvB,GADAI,EAAMJ,EAAI,OACL,CAACH,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,kGAAmGM,CAAI,CAAE,UAE5H,UAAU,OAAS,GAG9B,GAFAA,EAAMH,EACNE,EAAUD,EACL,CAACL,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,4EAA6EM,CAAI,CAAE,UAEtGP,EAAmBI,CAAM,EACpCG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAI,OACL,CAACH,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,kGAAmGM,CAAI,CAAE,EAEvID,EAAUF,CACX,CACA,OAAOI,EAAe,CAAC,CAAE,EASzB,SAASA,EAAeC,EAAO,CAC9B,OAAOC,EASP,SAASA,EAASC,EAAI,CACrB,IAAIC,EAAQH,EAAK,MAAM,EAEvB,OADAG,EAAM,QAASD,CAAE,EACZC,EAAM,OAASL,EACZC,EAAeI,CAAM,EAEtBT,EAAI,MAAOG,EAASM,CAAM,CAClC,CACD,CACD,CAKAd,EAAO,QAAUI,ICrEjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isPositiveInteger", "format", "curryRight", "fcn", "arity", "thisArg", "context", "len", "createCurried", "args", "curried", "v", "cargs", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7271aed..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,53 +0,0 @@ - -{{alias}}( fcn[, arity][, thisArg] ) - Transforms a function into a sequence of functions each accepting a single - argument. - - Until return value resolution, each invocation returns a new partially - applied curry function. - - This function applies arguments starting from the right. - - Parameters - ---------- - fcn: Function - Function to curry. - - arity: integer (optional) - Number of parameters. Default: `fcn.length`. - - thisArg: any (optional) - Evaluation context. - - Returns - ------- - out: Function - Curry function. - - Examples - -------- - > function add( x, y ) { return x + y; }; - > var f = {{alias}}( add ); - > var sum = f( 2 )( 3 ) - 5 - - // Supply arity: - > function add() { return arguments[ 0 ] + arguments[ 1 ]; }; - > f = {{alias}}( add, 2 ); - > sum = f( 2 )( 3 ) - 5 - - // Provide function context: - > var obj = { - ... 'name': 'Ada', - ... 'greet': function greet( word1, word2 ) { - ... return word1 + ' ' + word2 + ', ' + this.name + '!' - ... } - ... }; - > f = {{alias}}( obj.greet, obj ); - > var str = f( 'there' )( 'Hello' ) - 'Hello there, Ada!' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4577cdb..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,71 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import curryRight = require( './index' ); - - -// TESTS // - -// The function returns a function... -{ - curryRight( ( x: number, y: number ): number => x + y ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: number, y: number ): number => x + y, 2 ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: number, y: number ): number => x + y, 2, {} ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: string, y: string ): string => x + y, {} ); // $ExpectType (v: string) => (v: string) => string - curryRight( ( x: string, y: string ): string => x + y, 2, {} ); // $ExpectType (v: string) => (v: string) => string - curryRight( ( str: string, n: number ): string => str.substring( n ) ); // $ExpectType (v: number) => (v: string) => string - - const cxt = { - 'count': 0, - 'multiply': function multiply( this: { count: number }, x: number, y: number ): number { - this.count += 1; // eslint-disable-line no-invalid-this - return x * y; - } - }; - curryRight( cxt.multiply ); // $ExpectType (v: number) => (v: number) => number - curryRight( cxt.multiply, 2 ); // $ExpectType (v: number) => (v: number) => number - curryRight( cxt.multiply, 2, { 'count': 2 } ); // $ExpectType (v: number) => (v: number) => number -} - -// The compiler throws an error if the function is provided a first argument other than a function... -{ - curryRight( true ); // $ExpectError - curryRight( false ); // $ExpectError - curryRight( 5 ); // $ExpectError - curryRight( [] ); // $ExpectError - curryRight( {} ); // $ExpectError - curryRight( 'abc' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a this argument which does not constitute a valid `this` context... -{ - const cxt = { - 'count': 0, - 'multiply': function multiply( this: { count: number }, x: number, y: number ): number { - this.count += 1; // eslint-disable-line no-invalid-this - return x * y; - } - }; - curryRight( cxt.multiply, { 'COUNT': 2 } ); // $ExpectError - curryRight( cxt.multiply, 2, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided more than three arguments... -{ - curryRight( ( x: number, y: number ): number => x + y, 2, {}, 4 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 76818ec..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 curryRight = require( './../lib' ); - -var fcn; -var out; -var i; - -function add( x, y, z, w, t, s ) { - return x + y + z + w + t + s; -} - -fcn = curryRight( add ); -out = fcn; -for ( i = 0; i < add.length; i++ ) { - out = out( i*10 ); -} -console.log( out ); 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..b4bb434 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@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 s(s,n,i){var o,l;if(!e(s))throw new TypeError(t("1SN3c",s));if(arguments.length<2){if(l=s.length,!r(l))throw new TypeError(t("1SNEX",l))}else if(arguments.length>2){if(o=i,!r(l=n))throw new TypeError(t("1SNAz",l))}else if(r(n))l=n;else{if(l=s.length,!r(l))throw new TypeError(t("1SNEX",l));o=n}return function e(r){return t;function t(t){var n=r.slice();return n.unshift(t),n.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNAz', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNEX', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","curried","v","cargs","slice","unshift","apply"],"mappings":";;kTAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,SAEjC,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAEjC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvCD,EAAUF,CACV,CACD,OASA,SAASU,EAAeC,GACvB,OAAOC,EASP,SAASA,EAASC,GACjB,IAAIC,EAAQH,EAAKI,QAEjB,OADAD,EAAME,QAASH,GACVC,EAAMN,OAASL,EACZO,EAAeI,GAEhBf,EAAIkB,MAAOf,EAASY,EAC3B,CACD,CA3BMJ,CAAe,GA4BvB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 7e7d2e8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform a function into a sequence of functions each accepting a single argument. -* -* @module @stdlib/utils-curry-right -* -* @example -* var curryRight = require( '@stdlib/utils-curry-right' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ - -// 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 ffb671a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* @param {Function} fcn - function to curry -* @param {PositiveInteger} [arity=fcn.length] - number of parameters -* @param {*} [thisArg] - evaluation context -* @throws {TypeError} first argument must be a function -* @throws {TypeError} first argument must be a function having at least one parameter -* @throws {TypeError} `arity` argument must be a positive integer -* @returns {Function} curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -function curryRight( fcn, arity, thisArg ) { - var context; - var len; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '1SN3c', fcn ) ); - } - if ( arguments.length < 2 ) { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNEX', len ) ); - } - } else if ( arguments.length > 2 ) { - len = arity; - context = thisArg; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNAz', len ) ); - } - } else if ( isPositiveInteger( arity ) ) { - len = arity; - } else { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNEX', len ) ); - } - context = arity; - } - return createCurried( [] ); - - /** - * Returns a curry function. - * - * @private - * @param {Array} args - arguments - * @returns {Function} curry function - */ - function createCurried( args ) { - return curried; - - /** - * Curry function. - * - * @private - * @param {*} v - curried function parameter - * @returns {(Function|*)} partially applied curry function or curried function result - */ - function curried( v ) { - var cargs = args.slice(); - cargs.unshift( v ); - if ( cargs.length < len ) { - return createCurried( cargs ); - } - return fcn.apply( context, cargs ); - } - } -} - - -// EXPORTS // - -module.exports = curryRight; diff --git a/package.json b/package.json index 5e700a4..f269d93 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Transform a function into a sequence of functions each accepting a single argument.", "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/assert-is-positive-integer": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/math-base-ops-add3": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/random-base-randu": "^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.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..5c63fa1 --- /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 3f1273f..0000000 --- a/test/test.js +++ /dev/null @@ -1,285 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var add = require( '@stdlib/math-base-ops-add3' ); -var curryRight = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof curryRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (1 arg)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (2 args; context)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an arity argument which is not a positive integer (3 args)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - 0, - -1, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( add, value, {} ); - }; - } -}); - -tape( 'the function returns a function', function test( t ) { - var fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function curries a function', function test( t) { - var fcn; - var f; - - fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'for each invocation where the invocation number is less than the arity, the curried function returns a new partially applied curry function', function test( t ) { - var sum; - var f0; - var f1; - var f2; - - // Initial curried function has no partially applied arguments... - f0 = curryRight( add ); - - sum = f0( 1 )( 2 )( 3 ); - t.strictEqual( sum, 6, 'returns 6' ); - - sum = f0( 1 )( 3 )( 5 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f0( 10 )( 20 )( 40 ); - t.strictEqual( sum, 70, 'returns 70' ); - - // If arity greater than 1, first invocation returns a curried function with one partially applied argument... - f1 = f0( 2 ); - - sum = f1( 3 )( 4 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f1( 10 )( 20 ); - t.strictEqual( sum, 32, 'returns 32' ); - - sum = f1( -1 )( -2 ); - t.strictEqual( sum, -1, 'returns -1' ); - - // If arity greater than 2, second invocation returns a curried function with two partially applied arguments... - f2 = f1( 3 ); - - sum = f2( 5 ); - t.strictEqual( sum, 10, 'returns 10' ); - - sum = f2( 6 ); - t.strictEqual( sum, 11, 'returns 11' ); - - sum = f2( 10 ); - t.strictEqual( sum, 15, 'returns 15' ); - - // And so on and so forth... - - t.end(); -}); - -tape( 'the function supports specifying a function arity', function test( t ) { - var fcn; - var f; - - function add() { - return arguments[ 0 ] + arguments[ 1 ] + arguments[ 2 ]; - } - - fcn = curryRight( add, 3 ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'the function supports specifying a function context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate( length, units, type, color ) { - return this.style+': '+length+units+' '+type+' '+color; - } - }; - - fcn = curryRight( context.generate, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); - -tape( 'the function supports specifying a function arity and context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate() { - return this.style+': '+arguments[0]+arguments[1]+' '+arguments[2]+' '+arguments[3]; - } - }; - - fcn = curryRight( context.generate, 4, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); From c7810861fd102617a2733fe38a30ea2b56ccaf3c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 04:15:53 +0000 Subject: [PATCH 121/140] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index 8d7768e..ffb671a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -52,25 +52,25 @@ function curryRight( fcn, arity, thisArg ) { var context; var len; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '1SN3c', fcn ) ); } if ( arguments.length < 2 ) { len = fcn.length; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); + throw new TypeError( format( '1SNEX', len ) ); } } else if ( arguments.length > 2 ) { len = arity; context = thisArg; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) ); + throw new TypeError( format( '1SNAz', len ) ); } } else if ( isPositiveInteger( arity ) ) { len = arity; } else { len = fcn.length; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); + throw new TypeError( format( '1SNEX', len ) ); } context = arity; } diff --git a/package.json b/package.json index d433a32..5e700a4 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-function": "^0.2.2", "@stdlib/assert-is-positive-integer": "^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 8ff527531674803139d5daf0204a586241bd9df9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 07:45:19 +0000 Subject: [PATCH 122/140] Remove files --- index.d.ts | 116 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4963 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 5a84dff..0000000 --- a/index.d.ts +++ /dev/null @@ -1,116 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Utility type to reverse a tuple type. -*/ -type ReverseTuple> = T extends [infer First, ...infer Rest] ? [...ReverseTuple, First] : []; // eslint-disable-line @typescript-eslint/no-explicit-any - -/** -* Curry function type for curryRight. -*/ -type CurryRightFunction< - TThis, - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn -> = ( this: TThis, ...args: TArgs ) => TReturn; - -/** -* Curry function. -* -* @param v - curried function parameter -* @returns partially applied curry function or curried function result -*/ -type Closure< - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn -> = ReverseTuple extends [infer TFirst, ...infer TRest] - ? ( v: TFirst ) => Closure, TReturn> - : TReturn; - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param arity - number of parameters -* @param thisArg - evaluation context -* @throws `arity` must be a positive integer -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight< - TThis extends object, - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn ->( - fcn: CurryRightFunction, - arity: number, - thisArg?: TThis -): Closure; - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param thisArg - evaluation context -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight< - TThis extends object, - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn ->( - fcn: CurryRightFunction, - thisArg?: TThis -): Closure; - - -// EXPORTS // - -export = curryRight; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b4bb434..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@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 s(s,n,i){var o,l;if(!e(s))throw new TypeError(t("1SN3c",s));if(arguments.length<2){if(l=s.length,!r(l))throw new TypeError(t("1SNEX",l))}else if(arguments.length>2){if(o=i,!r(l=n))throw new TypeError(t("1SNAz",l))}else if(r(n))l=n;else{if(l=s.length,!r(l))throw new TypeError(t("1SNEX",l));o=n}return function e(r){return t;function t(t){var n=r.slice();return n.unshift(t),n.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNAz', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNEX', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","curried","v","cargs","slice","unshift","apply"],"mappings":";;kTAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,SAEjC,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAEjC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvCD,EAAUF,CACV,CACD,OASA,SAASU,EAAeC,GACvB,OAAOC,EASP,SAASA,EAASC,GACjB,IAAIC,EAAQH,EAAKI,QAEjB,OADAD,EAAME,QAASH,GACVC,EAAMN,OAASL,EACZO,EAAeI,GAEhBf,EAAIkB,MAAOf,EAASY,EAC3B,CACD,CA3BMJ,CAAe,GA4BvB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 5c63fa1..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 56b81f3a4586595a11397ae90d01406baa8e3897 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 07:45:34 +0000 Subject: [PATCH 123/140] 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 | 242 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 41 +- SECURITY.md | 5 - benchmark/benchmark.js | 90 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 53 - docs/types/test.ts | 71 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 110 - package.json | 57 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 285 -- 43 files changed, 4865 insertions(+), 4298 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 b5e9249..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-10-01T03:13:47.615Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2b7fad0..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/curry-right) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 9ffcfa1..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/curry-right) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 906f5af..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: '6 18 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -260,7 +251,7 @@ console.log( out ); ## 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]. @@ -325,11 +316,11 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry +[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry/tree/esm -[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry +[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry/tree/esm -[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right +[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right/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 69ca868..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isFunction = require( '@stdlib/assert-is-function' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var curryRight = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = curryRight( pow ); - if ( typeof out !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( out ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::returned_function', function benchmark( b ) { - var fcn; - var out; - var i; - - fcn = curryRight( pow ); - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = fcn( randu() )( randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::direct', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = pow( randu(), randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 7ef3db2..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/curry-right" -%% click B href "https://github.com/stdlib-js/utils-curry-right/tree/main" -%% click C href "https://github.com/stdlib-js/utils-curry-right/tree/production" -%% click D href "https://github.com/stdlib-js/utils-curry-right/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-curry-right/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-curry-right/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/curry-right -[production-url]: https://github.com/stdlib-js/utils-curry-right/tree/production -[deno-url]: https://github.com/stdlib-js/utils-curry-right/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-curry-right/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-curry-right/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-curry-right/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-curry-right/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-curry-right/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 8166962..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import curryRight from '../docs/types/index'; -export = curryRight; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 16477e0..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var g=f(function(b,o){ -var c=require('@stdlib/assert-is-function/dist'),n=require('@stdlib/assert-is-positive-integer/dist').isPrimitive,a=require('@stdlib/error-tools-fmtprodmsg/dist');function p(t,r,l){var u,e;if(!c(t))throw new TypeError(a('1SN3c',t));if(arguments.length<2){if(e=t.length,!n(e))throw new TypeError(a('1SNEX',e))}else if(arguments.length>2){if(e=r,u=l,!n(e))throw new TypeError(a('1SNAz',e))}else if(n(r))e=r;else{if(e=t.length,!n(e))throw new TypeError(a('1SNEX',e));u=r}return s([]);function s(m){return v;function v(h){var i=m.slice();return i.unshift(h),i.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = curryRight;\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* Transform a function into a sequence of functions each accepting a single argument.\n*\n* @module @stdlib/utils-curry-right\n*\n* @example\n* var curryRight = require( '@stdlib/utils-curry-right' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var f = curryRight( add );\n*\n* var sum = f( 2 )( 3 );\n* // returns 5\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,EAAoB,QAAS,oCAAqC,EAAE,YACpEC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,EAAYC,EAAKC,EAAOC,EAAU,CAC1C,IAAIC,EACAC,EACJ,GAAK,CAACR,EAAYI,CAAI,EACrB,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAI,CAAE,EAEzG,GAAK,UAAU,OAAS,GAEvB,GADAI,EAAMJ,EAAI,OACL,CAACH,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,kGAAmGM,CAAI,CAAE,UAE5H,UAAU,OAAS,GAG9B,GAFAA,EAAMH,EACNE,EAAUD,EACL,CAACL,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,4EAA6EM,CAAI,CAAE,UAEtGP,EAAmBI,CAAM,EACpCG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAI,OACL,CAACH,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,kGAAmGM,CAAI,CAAE,EAEvID,EAAUF,CACX,CACA,OAAOI,EAAe,CAAC,CAAE,EASzB,SAASA,EAAeC,EAAO,CAC9B,OAAOC,EASP,SAASA,EAASC,EAAI,CACrB,IAAIC,EAAQH,EAAK,MAAM,EAEvB,OADAG,EAAM,QAASD,CAAE,EACZC,EAAM,OAASL,EACZC,EAAeI,CAAM,EAEtBT,EAAI,MAAOG,EAASM,CAAM,CAClC,CACD,CACD,CAKAd,EAAO,QAAUI,ICrEjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isPositiveInteger", "format", "curryRight", "fcn", "arity", "thisArg", "context", "len", "createCurried", "args", "curried", "v", "cargs", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7271aed..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,53 +0,0 @@ - -{{alias}}( fcn[, arity][, thisArg] ) - Transforms a function into a sequence of functions each accepting a single - argument. - - Until return value resolution, each invocation returns a new partially - applied curry function. - - This function applies arguments starting from the right. - - Parameters - ---------- - fcn: Function - Function to curry. - - arity: integer (optional) - Number of parameters. Default: `fcn.length`. - - thisArg: any (optional) - Evaluation context. - - Returns - ------- - out: Function - Curry function. - - Examples - -------- - > function add( x, y ) { return x + y; }; - > var f = {{alias}}( add ); - > var sum = f( 2 )( 3 ) - 5 - - // Supply arity: - > function add() { return arguments[ 0 ] + arguments[ 1 ]; }; - > f = {{alias}}( add, 2 ); - > sum = f( 2 )( 3 ) - 5 - - // Provide function context: - > var obj = { - ... 'name': 'Ada', - ... 'greet': function greet( word1, word2 ) { - ... return word1 + ' ' + word2 + ', ' + this.name + '!' - ... } - ... }; - > f = {{alias}}( obj.greet, obj ); - > var str = f( 'there' )( 'Hello' ) - 'Hello there, Ada!' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4577cdb..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,71 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import curryRight = require( './index' ); - - -// TESTS // - -// The function returns a function... -{ - curryRight( ( x: number, y: number ): number => x + y ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: number, y: number ): number => x + y, 2 ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: number, y: number ): number => x + y, 2, {} ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: string, y: string ): string => x + y, {} ); // $ExpectType (v: string) => (v: string) => string - curryRight( ( x: string, y: string ): string => x + y, 2, {} ); // $ExpectType (v: string) => (v: string) => string - curryRight( ( str: string, n: number ): string => str.substring( n ) ); // $ExpectType (v: number) => (v: string) => string - - const cxt = { - 'count': 0, - 'multiply': function multiply( this: { count: number }, x: number, y: number ): number { - this.count += 1; // eslint-disable-line no-invalid-this - return x * y; - } - }; - curryRight( cxt.multiply ); // $ExpectType (v: number) => (v: number) => number - curryRight( cxt.multiply, 2 ); // $ExpectType (v: number) => (v: number) => number - curryRight( cxt.multiply, 2, { 'count': 2 } ); // $ExpectType (v: number) => (v: number) => number -} - -// The compiler throws an error if the function is provided a first argument other than a function... -{ - curryRight( true ); // $ExpectError - curryRight( false ); // $ExpectError - curryRight( 5 ); // $ExpectError - curryRight( [] ); // $ExpectError - curryRight( {} ); // $ExpectError - curryRight( 'abc' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a this argument which does not constitute a valid `this` context... -{ - const cxt = { - 'count': 0, - 'multiply': function multiply( this: { count: number }, x: number, y: number ): number { - this.count += 1; // eslint-disable-line no-invalid-this - return x * y; - } - }; - curryRight( cxt.multiply, { 'COUNT': 2 } ); // $ExpectError - curryRight( cxt.multiply, 2, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided more than three arguments... -{ - curryRight( ( x: number, y: number ): number => x + y, 2, {}, 4 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 76818ec..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 curryRight = require( './../lib' ); - -var fcn; -var out; -var i; - -function add( x, y, z, w, t, s ) { - return x + y + z + w + t + s; -} - -fcn = curryRight( add ); -out = fcn; -for ( i = 0; i < add.length; i++ ) { - out = out( i*10 ); -} -console.log( out ); 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..b4bb434 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@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 s(s,n,i){var o,l;if(!e(s))throw new TypeError(t("1SN3c",s));if(arguments.length<2){if(l=s.length,!r(l))throw new TypeError(t("1SNEX",l))}else if(arguments.length>2){if(o=i,!r(l=n))throw new TypeError(t("1SNAz",l))}else if(r(n))l=n;else{if(l=s.length,!r(l))throw new TypeError(t("1SNEX",l));o=n}return function e(r){return t;function t(t){var n=r.slice();return n.unshift(t),n.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNAz', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNEX', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","curried","v","cargs","slice","unshift","apply"],"mappings":";;kTAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,SAEjC,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAEjC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvCD,EAAUF,CACV,CACD,OASA,SAASU,EAAeC,GACvB,OAAOC,EASP,SAASA,EAASC,GACjB,IAAIC,EAAQH,EAAKI,QAEjB,OADAD,EAAME,QAASH,GACVC,EAAMN,OAASL,EACZO,EAAeI,GAEhBf,EAAIkB,MAAOf,EAASY,EAC3B,CACD,CA3BMJ,CAAe,GA4BvB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 7e7d2e8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform a function into a sequence of functions each accepting a single argument. -* -* @module @stdlib/utils-curry-right -* -* @example -* var curryRight = require( '@stdlib/utils-curry-right' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ - -// 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 ffb671a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* @param {Function} fcn - function to curry -* @param {PositiveInteger} [arity=fcn.length] - number of parameters -* @param {*} [thisArg] - evaluation context -* @throws {TypeError} first argument must be a function -* @throws {TypeError} first argument must be a function having at least one parameter -* @throws {TypeError} `arity` argument must be a positive integer -* @returns {Function} curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -function curryRight( fcn, arity, thisArg ) { - var context; - var len; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '1SN3c', fcn ) ); - } - if ( arguments.length < 2 ) { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNEX', len ) ); - } - } else if ( arguments.length > 2 ) { - len = arity; - context = thisArg; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNAz', len ) ); - } - } else if ( isPositiveInteger( arity ) ) { - len = arity; - } else { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNEX', len ) ); - } - context = arity; - } - return createCurried( [] ); - - /** - * Returns a curry function. - * - * @private - * @param {Array} args - arguments - * @returns {Function} curry function - */ - function createCurried( args ) { - return curried; - - /** - * Curry function. - * - * @private - * @param {*} v - curried function parameter - * @returns {(Function|*)} partially applied curry function or curried function result - */ - function curried( v ) { - var cargs = args.slice(); - cargs.unshift( v ); - if ( cargs.length < len ) { - return createCurried( cargs ); - } - return fcn.apply( context, cargs ); - } - } -} - - -// EXPORTS // - -module.exports = curryRight; diff --git a/package.json b/package.json index 5e700a4..f269d93 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Transform a function into a sequence of functions each accepting a single argument.", "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/assert-is-positive-integer": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/math-base-ops-add3": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/random-base-randu": "^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.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..5c63fa1 --- /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 3f1273f..0000000 --- a/test/test.js +++ /dev/null @@ -1,285 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var add = require( '@stdlib/math-base-ops-add3' ); -var curryRight = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof curryRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (1 arg)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (2 args; context)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an arity argument which is not a positive integer (3 args)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - 0, - -1, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( add, value, {} ); - }; - } -}); - -tape( 'the function returns a function', function test( t ) { - var fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function curries a function', function test( t) { - var fcn; - var f; - - fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'for each invocation where the invocation number is less than the arity, the curried function returns a new partially applied curry function', function test( t ) { - var sum; - var f0; - var f1; - var f2; - - // Initial curried function has no partially applied arguments... - f0 = curryRight( add ); - - sum = f0( 1 )( 2 )( 3 ); - t.strictEqual( sum, 6, 'returns 6' ); - - sum = f0( 1 )( 3 )( 5 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f0( 10 )( 20 )( 40 ); - t.strictEqual( sum, 70, 'returns 70' ); - - // If arity greater than 1, first invocation returns a curried function with one partially applied argument... - f1 = f0( 2 ); - - sum = f1( 3 )( 4 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f1( 10 )( 20 ); - t.strictEqual( sum, 32, 'returns 32' ); - - sum = f1( -1 )( -2 ); - t.strictEqual( sum, -1, 'returns -1' ); - - // If arity greater than 2, second invocation returns a curried function with two partially applied arguments... - f2 = f1( 3 ); - - sum = f2( 5 ); - t.strictEqual( sum, 10, 'returns 10' ); - - sum = f2( 6 ); - t.strictEqual( sum, 11, 'returns 11' ); - - sum = f2( 10 ); - t.strictEqual( sum, 15, 'returns 15' ); - - // And so on and so forth... - - t.end(); -}); - -tape( 'the function supports specifying a function arity', function test( t ) { - var fcn; - var f; - - function add() { - return arguments[ 0 ] + arguments[ 1 ] + arguments[ 2 ]; - } - - fcn = curryRight( add, 3 ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'the function supports specifying a function context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate( length, units, type, color ) { - return this.style+': '+length+units+' '+type+' '+color; - } - }; - - fcn = curryRight( context.generate, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); - -tape( 'the function supports specifying a function arity and context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate() { - return this.style+': '+arguments[0]+arguments[1]+' '+arguments[2]+' '+arguments[3]; - } - }; - - fcn = curryRight( context.generate, 4, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); From bc4e0134c76f0c54300ffc0bd25c35a37d96e35d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 04:14:00 +0000 Subject: [PATCH 124/140] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index 8d7768e..ffb671a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -52,25 +52,25 @@ function curryRight( fcn, arity, thisArg ) { var context; var len; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '1SN3c', fcn ) ); } if ( arguments.length < 2 ) { len = fcn.length; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); + throw new TypeError( format( '1SNEX', len ) ); } } else if ( arguments.length > 2 ) { len = arity; context = thisArg; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) ); + throw new TypeError( format( '1SNAz', len ) ); } } else if ( isPositiveInteger( arity ) ) { len = arity; } else { len = fcn.length; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); + throw new TypeError( format( '1SNEX', len ) ); } context = arity; } diff --git a/package.json b/package.json index d433a32..5e700a4 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-function": "^0.2.2", "@stdlib/assert-is-positive-integer": "^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 4a7c8c23ff6f0dd18682c92c6c1712429dac4755 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 07:20:49 +0000 Subject: [PATCH 125/140] Remove files --- index.d.ts | 116 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4963 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 5a84dff..0000000 --- a/index.d.ts +++ /dev/null @@ -1,116 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Utility type to reverse a tuple type. -*/ -type ReverseTuple> = T extends [infer First, ...infer Rest] ? [...ReverseTuple, First] : []; // eslint-disable-line @typescript-eslint/no-explicit-any - -/** -* Curry function type for curryRight. -*/ -type CurryRightFunction< - TThis, - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn -> = ( this: TThis, ...args: TArgs ) => TReturn; - -/** -* Curry function. -* -* @param v - curried function parameter -* @returns partially applied curry function or curried function result -*/ -type Closure< - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn -> = ReverseTuple extends [infer TFirst, ...infer TRest] - ? ( v: TFirst ) => Closure, TReturn> - : TReturn; - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param arity - number of parameters -* @param thisArg - evaluation context -* @throws `arity` must be a positive integer -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight< - TThis extends object, - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn ->( - fcn: CurryRightFunction, - arity: number, - thisArg?: TThis -): Closure; - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param thisArg - evaluation context -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight< - TThis extends object, - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn ->( - fcn: CurryRightFunction, - thisArg?: TThis -): Closure; - - -// EXPORTS // - -export = curryRight; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b4bb434..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@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 s(s,n,i){var o,l;if(!e(s))throw new TypeError(t("1SN3c",s));if(arguments.length<2){if(l=s.length,!r(l))throw new TypeError(t("1SNEX",l))}else if(arguments.length>2){if(o=i,!r(l=n))throw new TypeError(t("1SNAz",l))}else if(r(n))l=n;else{if(l=s.length,!r(l))throw new TypeError(t("1SNEX",l));o=n}return function e(r){return t;function t(t){var n=r.slice();return n.unshift(t),n.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNAz', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNEX', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","curried","v","cargs","slice","unshift","apply"],"mappings":";;kTAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,SAEjC,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAEjC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvCD,EAAUF,CACV,CACD,OASA,SAASU,EAAeC,GACvB,OAAOC,EASP,SAASA,EAASC,GACjB,IAAIC,EAAQH,EAAKI,QAEjB,OADAD,EAAME,QAASH,GACVC,EAAMN,OAASL,EACZO,EAAeI,GAEhBf,EAAIkB,MAAOf,EAASY,EAC3B,CACD,CA3BMJ,CAAe,GA4BvB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 5c63fa1..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From e19810aa3d104b6f7dfabfeda4750b3115ce2b81 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 07:21:02 +0000 Subject: [PATCH 126/140] 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 | 242 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 41 +- SECURITY.md | 5 - benchmark/benchmark.js | 90 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 53 - docs/types/test.ts | 71 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 110 - package.json | 57 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 285 -- 43 files changed, 4865 insertions(+), 4298 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 64cebd9..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-11-01T03:15:15.280Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2b7fad0..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/curry-right) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 9ffcfa1..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/curry-right) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 906f5af..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: '6 18 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -260,7 +251,7 @@ console.log( out ); ## 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]. @@ -325,11 +316,11 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry +[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry/tree/esm -[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry +[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry/tree/esm -[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right +[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right/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 69ca868..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isFunction = require( '@stdlib/assert-is-function' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var curryRight = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = curryRight( pow ); - if ( typeof out !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( out ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::returned_function', function benchmark( b ) { - var fcn; - var out; - var i; - - fcn = curryRight( pow ); - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = fcn( randu() )( randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::direct', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = pow( randu(), randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 7ef3db2..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/curry-right" -%% click B href "https://github.com/stdlib-js/utils-curry-right/tree/main" -%% click C href "https://github.com/stdlib-js/utils-curry-right/tree/production" -%% click D href "https://github.com/stdlib-js/utils-curry-right/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-curry-right/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-curry-right/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/curry-right -[production-url]: https://github.com/stdlib-js/utils-curry-right/tree/production -[deno-url]: https://github.com/stdlib-js/utils-curry-right/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-curry-right/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-curry-right/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-curry-right/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-curry-right/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-curry-right/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 8166962..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import curryRight from '../docs/types/index'; -export = curryRight; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 16477e0..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var g=f(function(b,o){ -var c=require('@stdlib/assert-is-function/dist'),n=require('@stdlib/assert-is-positive-integer/dist').isPrimitive,a=require('@stdlib/error-tools-fmtprodmsg/dist');function p(t,r,l){var u,e;if(!c(t))throw new TypeError(a('1SN3c',t));if(arguments.length<2){if(e=t.length,!n(e))throw new TypeError(a('1SNEX',e))}else if(arguments.length>2){if(e=r,u=l,!n(e))throw new TypeError(a('1SNAz',e))}else if(n(r))e=r;else{if(e=t.length,!n(e))throw new TypeError(a('1SNEX',e));u=r}return s([]);function s(m){return v;function v(h){var i=m.slice();return i.unshift(h),i.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = curryRight;\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* Transform a function into a sequence of functions each accepting a single argument.\n*\n* @module @stdlib/utils-curry-right\n*\n* @example\n* var curryRight = require( '@stdlib/utils-curry-right' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var f = curryRight( add );\n*\n* var sum = f( 2 )( 3 );\n* // returns 5\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,EAAoB,QAAS,oCAAqC,EAAE,YACpEC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,EAAYC,EAAKC,EAAOC,EAAU,CAC1C,IAAIC,EACAC,EACJ,GAAK,CAACR,EAAYI,CAAI,EACrB,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAI,CAAE,EAEzG,GAAK,UAAU,OAAS,GAEvB,GADAI,EAAMJ,EAAI,OACL,CAACH,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,kGAAmGM,CAAI,CAAE,UAE5H,UAAU,OAAS,GAG9B,GAFAA,EAAMH,EACNE,EAAUD,EACL,CAACL,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,4EAA6EM,CAAI,CAAE,UAEtGP,EAAmBI,CAAM,EACpCG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAI,OACL,CAACH,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,kGAAmGM,CAAI,CAAE,EAEvID,EAAUF,CACX,CACA,OAAOI,EAAe,CAAC,CAAE,EASzB,SAASA,EAAeC,EAAO,CAC9B,OAAOC,EASP,SAASA,EAASC,EAAI,CACrB,IAAIC,EAAQH,EAAK,MAAM,EAEvB,OADAG,EAAM,QAASD,CAAE,EACZC,EAAM,OAASL,EACZC,EAAeI,CAAM,EAEtBT,EAAI,MAAOG,EAASM,CAAM,CAClC,CACD,CACD,CAKAd,EAAO,QAAUI,ICrEjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isPositiveInteger", "format", "curryRight", "fcn", "arity", "thisArg", "context", "len", "createCurried", "args", "curried", "v", "cargs", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7271aed..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,53 +0,0 @@ - -{{alias}}( fcn[, arity][, thisArg] ) - Transforms a function into a sequence of functions each accepting a single - argument. - - Until return value resolution, each invocation returns a new partially - applied curry function. - - This function applies arguments starting from the right. - - Parameters - ---------- - fcn: Function - Function to curry. - - arity: integer (optional) - Number of parameters. Default: `fcn.length`. - - thisArg: any (optional) - Evaluation context. - - Returns - ------- - out: Function - Curry function. - - Examples - -------- - > function add( x, y ) { return x + y; }; - > var f = {{alias}}( add ); - > var sum = f( 2 )( 3 ) - 5 - - // Supply arity: - > function add() { return arguments[ 0 ] + arguments[ 1 ]; }; - > f = {{alias}}( add, 2 ); - > sum = f( 2 )( 3 ) - 5 - - // Provide function context: - > var obj = { - ... 'name': 'Ada', - ... 'greet': function greet( word1, word2 ) { - ... return word1 + ' ' + word2 + ', ' + this.name + '!' - ... } - ... }; - > f = {{alias}}( obj.greet, obj ); - > var str = f( 'there' )( 'Hello' ) - 'Hello there, Ada!' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4577cdb..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,71 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import curryRight = require( './index' ); - - -// TESTS // - -// The function returns a function... -{ - curryRight( ( x: number, y: number ): number => x + y ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: number, y: number ): number => x + y, 2 ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: number, y: number ): number => x + y, 2, {} ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: string, y: string ): string => x + y, {} ); // $ExpectType (v: string) => (v: string) => string - curryRight( ( x: string, y: string ): string => x + y, 2, {} ); // $ExpectType (v: string) => (v: string) => string - curryRight( ( str: string, n: number ): string => str.substring( n ) ); // $ExpectType (v: number) => (v: string) => string - - const cxt = { - 'count': 0, - 'multiply': function multiply( this: { count: number }, x: number, y: number ): number { - this.count += 1; // eslint-disable-line no-invalid-this - return x * y; - } - }; - curryRight( cxt.multiply ); // $ExpectType (v: number) => (v: number) => number - curryRight( cxt.multiply, 2 ); // $ExpectType (v: number) => (v: number) => number - curryRight( cxt.multiply, 2, { 'count': 2 } ); // $ExpectType (v: number) => (v: number) => number -} - -// The compiler throws an error if the function is provided a first argument other than a function... -{ - curryRight( true ); // $ExpectError - curryRight( false ); // $ExpectError - curryRight( 5 ); // $ExpectError - curryRight( [] ); // $ExpectError - curryRight( {} ); // $ExpectError - curryRight( 'abc' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a this argument which does not constitute a valid `this` context... -{ - const cxt = { - 'count': 0, - 'multiply': function multiply( this: { count: number }, x: number, y: number ): number { - this.count += 1; // eslint-disable-line no-invalid-this - return x * y; - } - }; - curryRight( cxt.multiply, { 'COUNT': 2 } ); // $ExpectError - curryRight( cxt.multiply, 2, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided more than three arguments... -{ - curryRight( ( x: number, y: number ): number => x + y, 2, {}, 4 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 76818ec..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 curryRight = require( './../lib' ); - -var fcn; -var out; -var i; - -function add( x, y, z, w, t, s ) { - return x + y + z + w + t + s; -} - -fcn = curryRight( add ); -out = fcn; -for ( i = 0; i < add.length; i++ ) { - out = out( i*10 ); -} -console.log( out ); 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..b4bb434 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@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 s(s,n,i){var o,l;if(!e(s))throw new TypeError(t("1SN3c",s));if(arguments.length<2){if(l=s.length,!r(l))throw new TypeError(t("1SNEX",l))}else if(arguments.length>2){if(o=i,!r(l=n))throw new TypeError(t("1SNAz",l))}else if(r(n))l=n;else{if(l=s.length,!r(l))throw new TypeError(t("1SNEX",l));o=n}return function e(r){return t;function t(t){var n=r.slice();return n.unshift(t),n.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNAz', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNEX', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","curried","v","cargs","slice","unshift","apply"],"mappings":";;kTAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,SAEjC,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAEjC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvCD,EAAUF,CACV,CACD,OASA,SAASU,EAAeC,GACvB,OAAOC,EASP,SAASA,EAASC,GACjB,IAAIC,EAAQH,EAAKI,QAEjB,OADAD,EAAME,QAASH,GACVC,EAAMN,OAASL,EACZO,EAAeI,GAEhBf,EAAIkB,MAAOf,EAASY,EAC3B,CACD,CA3BMJ,CAAe,GA4BvB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 7e7d2e8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform a function into a sequence of functions each accepting a single argument. -* -* @module @stdlib/utils-curry-right -* -* @example -* var curryRight = require( '@stdlib/utils-curry-right' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ - -// 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 ffb671a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* @param {Function} fcn - function to curry -* @param {PositiveInteger} [arity=fcn.length] - number of parameters -* @param {*} [thisArg] - evaluation context -* @throws {TypeError} first argument must be a function -* @throws {TypeError} first argument must be a function having at least one parameter -* @throws {TypeError} `arity` argument must be a positive integer -* @returns {Function} curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -function curryRight( fcn, arity, thisArg ) { - var context; - var len; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '1SN3c', fcn ) ); - } - if ( arguments.length < 2 ) { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNEX', len ) ); - } - } else if ( arguments.length > 2 ) { - len = arity; - context = thisArg; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNAz', len ) ); - } - } else if ( isPositiveInteger( arity ) ) { - len = arity; - } else { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNEX', len ) ); - } - context = arity; - } - return createCurried( [] ); - - /** - * Returns a curry function. - * - * @private - * @param {Array} args - arguments - * @returns {Function} curry function - */ - function createCurried( args ) { - return curried; - - /** - * Curry function. - * - * @private - * @param {*} v - curried function parameter - * @returns {(Function|*)} partially applied curry function or curried function result - */ - function curried( v ) { - var cargs = args.slice(); - cargs.unshift( v ); - if ( cargs.length < len ) { - return createCurried( cargs ); - } - return fcn.apply( context, cargs ); - } - } -} - - -// EXPORTS // - -module.exports = curryRight; diff --git a/package.json b/package.json index 5e700a4..f269d93 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Transform a function into a sequence of functions each accepting a single argument.", "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/assert-is-positive-integer": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/math-base-ops-add3": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/random-base-randu": "^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.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..5c63fa1 --- /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 3f1273f..0000000 --- a/test/test.js +++ /dev/null @@ -1,285 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var add = require( '@stdlib/math-base-ops-add3' ); -var curryRight = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof curryRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (1 arg)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (2 args; context)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an arity argument which is not a positive integer (3 args)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - 0, - -1, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( add, value, {} ); - }; - } -}); - -tape( 'the function returns a function', function test( t ) { - var fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function curries a function', function test( t) { - var fcn; - var f; - - fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'for each invocation where the invocation number is less than the arity, the curried function returns a new partially applied curry function', function test( t ) { - var sum; - var f0; - var f1; - var f2; - - // Initial curried function has no partially applied arguments... - f0 = curryRight( add ); - - sum = f0( 1 )( 2 )( 3 ); - t.strictEqual( sum, 6, 'returns 6' ); - - sum = f0( 1 )( 3 )( 5 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f0( 10 )( 20 )( 40 ); - t.strictEqual( sum, 70, 'returns 70' ); - - // If arity greater than 1, first invocation returns a curried function with one partially applied argument... - f1 = f0( 2 ); - - sum = f1( 3 )( 4 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f1( 10 )( 20 ); - t.strictEqual( sum, 32, 'returns 32' ); - - sum = f1( -1 )( -2 ); - t.strictEqual( sum, -1, 'returns -1' ); - - // If arity greater than 2, second invocation returns a curried function with two partially applied arguments... - f2 = f1( 3 ); - - sum = f2( 5 ); - t.strictEqual( sum, 10, 'returns 10' ); - - sum = f2( 6 ); - t.strictEqual( sum, 11, 'returns 11' ); - - sum = f2( 10 ); - t.strictEqual( sum, 15, 'returns 15' ); - - // And so on and so forth... - - t.end(); -}); - -tape( 'the function supports specifying a function arity', function test( t ) { - var fcn; - var f; - - function add() { - return arguments[ 0 ] + arguments[ 1 ] + arguments[ 2 ]; - } - - fcn = curryRight( add, 3 ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'the function supports specifying a function context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate( length, units, type, color ) { - return this.style+': '+length+units+' '+type+' '+color; - } - }; - - fcn = curryRight( context.generate, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); - -tape( 'the function supports specifying a function arity and context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate() { - return this.style+': '+arguments[0]+arguments[1]+' '+arguments[2]+' '+arguments[3]; - } - }; - - fcn = curryRight( context.generate, 4, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); From f3573a4eedb928665d253864a278eab4d85c0b5e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 04:28:01 +0000 Subject: [PATCH 127/140] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index 8d7768e..ffb671a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -52,25 +52,25 @@ function curryRight( fcn, arity, thisArg ) { var context; var len; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '1SN3c', fcn ) ); } if ( arguments.length < 2 ) { len = fcn.length; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); + throw new TypeError( format( '1SNEX', len ) ); } } else if ( arguments.length > 2 ) { len = arity; context = thisArg; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) ); + throw new TypeError( format( '1SNAz', len ) ); } } else if ( isPositiveInteger( arity ) ) { len = arity; } else { len = fcn.length; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); + throw new TypeError( format( '1SNEX', len ) ); } context = arity; } diff --git a/package.json b/package.json index d433a32..5e700a4 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-function": "^0.2.2", "@stdlib/assert-is-positive-integer": "^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 1db6a2f201736244e5e87ac36ad98b9f4e476689 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 07:55:13 +0000 Subject: [PATCH 128/140] Remove files --- index.d.ts | 116 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4963 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 5a84dff..0000000 --- a/index.d.ts +++ /dev/null @@ -1,116 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Utility type to reverse a tuple type. -*/ -type ReverseTuple> = T extends [infer First, ...infer Rest] ? [...ReverseTuple, First] : []; // eslint-disable-line @typescript-eslint/no-explicit-any - -/** -* Curry function type for curryRight. -*/ -type CurryRightFunction< - TThis, - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn -> = ( this: TThis, ...args: TArgs ) => TReturn; - -/** -* Curry function. -* -* @param v - curried function parameter -* @returns partially applied curry function or curried function result -*/ -type Closure< - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn -> = ReverseTuple extends [infer TFirst, ...infer TRest] - ? ( v: TFirst ) => Closure, TReturn> - : TReturn; - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param arity - number of parameters -* @param thisArg - evaluation context -* @throws `arity` must be a positive integer -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight< - TThis extends object, - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn ->( - fcn: CurryRightFunction, - arity: number, - thisArg?: TThis -): Closure; - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param thisArg - evaluation context -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight< - TThis extends object, - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn ->( - fcn: CurryRightFunction, - thisArg?: TThis -): Closure; - - -// EXPORTS // - -export = curryRight; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b4bb434..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@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 s(s,n,i){var o,l;if(!e(s))throw new TypeError(t("1SN3c",s));if(arguments.length<2){if(l=s.length,!r(l))throw new TypeError(t("1SNEX",l))}else if(arguments.length>2){if(o=i,!r(l=n))throw new TypeError(t("1SNAz",l))}else if(r(n))l=n;else{if(l=s.length,!r(l))throw new TypeError(t("1SNEX",l));o=n}return function e(r){return t;function t(t){var n=r.slice();return n.unshift(t),n.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNAz', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNEX', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","curried","v","cargs","slice","unshift","apply"],"mappings":";;kTAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,SAEjC,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAEjC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvCD,EAAUF,CACV,CACD,OASA,SAASU,EAAeC,GACvB,OAAOC,EASP,SAASA,EAASC,GACjB,IAAIC,EAAQH,EAAKI,QAEjB,OADAD,EAAME,QAASH,GACVC,EAAMN,OAASL,EACZO,EAAeI,GAEhBf,EAAIkB,MAAOf,EAASY,EAC3B,CACD,CA3BMJ,CAAe,GA4BvB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 5c63fa1..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 88234c542c3bc240819d21ac4a365cbef5d64b2d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 07:55:27 +0000 Subject: [PATCH 129/140] 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 | 242 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 41 +- SECURITY.md | 5 - benchmark/benchmark.js | 90 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 53 - docs/types/test.ts | 71 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 110 - package.json | 57 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 285 -- 44 files changed, 4865 insertions(+), 4403 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 a91a61c..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-12-01T03:20:40.846Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2b7fad0..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/curry-right) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 9ffcfa1..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/curry-right) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 906f5af..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: '6 18 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -260,7 +251,7 @@ console.log( out ); ## 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]. @@ -325,11 +316,11 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry +[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry/tree/esm -[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry +[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry/tree/esm -[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right +[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right/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 69ca868..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isFunction = require( '@stdlib/assert-is-function' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var curryRight = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = curryRight( pow ); - if ( typeof out !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( out ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::returned_function', function benchmark( b ) { - var fcn; - var out; - var i; - - fcn = curryRight( pow ); - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = fcn( randu() )( randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::direct', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = pow( randu(), randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 7ef3db2..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/curry-right" -%% click B href "https://github.com/stdlib-js/utils-curry-right/tree/main" -%% click C href "https://github.com/stdlib-js/utils-curry-right/tree/production" -%% click D href "https://github.com/stdlib-js/utils-curry-right/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-curry-right/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-curry-right/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/curry-right -[production-url]: https://github.com/stdlib-js/utils-curry-right/tree/production -[deno-url]: https://github.com/stdlib-js/utils-curry-right/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-curry-right/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-curry-right/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-curry-right/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-curry-right/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-curry-right/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 8166962..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import curryRight from '../docs/types/index'; -export = curryRight; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 16477e0..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var g=f(function(b,o){ -var c=require('@stdlib/assert-is-function/dist'),n=require('@stdlib/assert-is-positive-integer/dist').isPrimitive,a=require('@stdlib/error-tools-fmtprodmsg/dist');function p(t,r,l){var u,e;if(!c(t))throw new TypeError(a('1SN3c',t));if(arguments.length<2){if(e=t.length,!n(e))throw new TypeError(a('1SNEX',e))}else if(arguments.length>2){if(e=r,u=l,!n(e))throw new TypeError(a('1SNAz',e))}else if(n(r))e=r;else{if(e=t.length,!n(e))throw new TypeError(a('1SNEX',e));u=r}return s([]);function s(m){return v;function v(h){var i=m.slice();return i.unshift(h),i.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = curryRight;\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* Transform a function into a sequence of functions each accepting a single argument.\n*\n* @module @stdlib/utils-curry-right\n*\n* @example\n* var curryRight = require( '@stdlib/utils-curry-right' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var f = curryRight( add );\n*\n* var sum = f( 2 )( 3 );\n* // returns 5\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,EAAoB,QAAS,oCAAqC,EAAE,YACpEC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,EAAYC,EAAKC,EAAOC,EAAU,CAC1C,IAAIC,EACAC,EACJ,GAAK,CAACR,EAAYI,CAAI,EACrB,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAI,CAAE,EAEzG,GAAK,UAAU,OAAS,GAEvB,GADAI,EAAMJ,EAAI,OACL,CAACH,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,kGAAmGM,CAAI,CAAE,UAE5H,UAAU,OAAS,GAG9B,GAFAA,EAAMH,EACNE,EAAUD,EACL,CAACL,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,4EAA6EM,CAAI,CAAE,UAEtGP,EAAmBI,CAAM,EACpCG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAI,OACL,CAACH,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,kGAAmGM,CAAI,CAAE,EAEvID,EAAUF,CACX,CACA,OAAOI,EAAe,CAAC,CAAE,EASzB,SAASA,EAAeC,EAAO,CAC9B,OAAOC,EASP,SAASA,EAASC,EAAI,CACrB,IAAIC,EAAQH,EAAK,MAAM,EAEvB,OADAG,EAAM,QAASD,CAAE,EACZC,EAAM,OAASL,EACZC,EAAeI,CAAM,EAEtBT,EAAI,MAAOG,EAASM,CAAM,CAClC,CACD,CACD,CAKAd,EAAO,QAAUI,ICrEjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isPositiveInteger", "format", "curryRight", "fcn", "arity", "thisArg", "context", "len", "createCurried", "args", "curried", "v", "cargs", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7271aed..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,53 +0,0 @@ - -{{alias}}( fcn[, arity][, thisArg] ) - Transforms a function into a sequence of functions each accepting a single - argument. - - Until return value resolution, each invocation returns a new partially - applied curry function. - - This function applies arguments starting from the right. - - Parameters - ---------- - fcn: Function - Function to curry. - - arity: integer (optional) - Number of parameters. Default: `fcn.length`. - - thisArg: any (optional) - Evaluation context. - - Returns - ------- - out: Function - Curry function. - - Examples - -------- - > function add( x, y ) { return x + y; }; - > var f = {{alias}}( add ); - > var sum = f( 2 )( 3 ) - 5 - - // Supply arity: - > function add() { return arguments[ 0 ] + arguments[ 1 ]; }; - > f = {{alias}}( add, 2 ); - > sum = f( 2 )( 3 ) - 5 - - // Provide function context: - > var obj = { - ... 'name': 'Ada', - ... 'greet': function greet( word1, word2 ) { - ... return word1 + ' ' + word2 + ', ' + this.name + '!' - ... } - ... }; - > f = {{alias}}( obj.greet, obj ); - > var str = f( 'there' )( 'Hello' ) - 'Hello there, Ada!' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4577cdb..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,71 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import curryRight = require( './index' ); - - -// TESTS // - -// The function returns a function... -{ - curryRight( ( x: number, y: number ): number => x + y ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: number, y: number ): number => x + y, 2 ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: number, y: number ): number => x + y, 2, {} ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: string, y: string ): string => x + y, {} ); // $ExpectType (v: string) => (v: string) => string - curryRight( ( x: string, y: string ): string => x + y, 2, {} ); // $ExpectType (v: string) => (v: string) => string - curryRight( ( str: string, n: number ): string => str.substring( n ) ); // $ExpectType (v: number) => (v: string) => string - - const cxt = { - 'count': 0, - 'multiply': function multiply( this: { count: number }, x: number, y: number ): number { - this.count += 1; // eslint-disable-line no-invalid-this - return x * y; - } - }; - curryRight( cxt.multiply ); // $ExpectType (v: number) => (v: number) => number - curryRight( cxt.multiply, 2 ); // $ExpectType (v: number) => (v: number) => number - curryRight( cxt.multiply, 2, { 'count': 2 } ); // $ExpectType (v: number) => (v: number) => number -} - -// The compiler throws an error if the function is provided a first argument other than a function... -{ - curryRight( true ); // $ExpectError - curryRight( false ); // $ExpectError - curryRight( 5 ); // $ExpectError - curryRight( [] ); // $ExpectError - curryRight( {} ); // $ExpectError - curryRight( 'abc' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a this argument which does not constitute a valid `this` context... -{ - const cxt = { - 'count': 0, - 'multiply': function multiply( this: { count: number }, x: number, y: number ): number { - this.count += 1; // eslint-disable-line no-invalid-this - return x * y; - } - }; - curryRight( cxt.multiply, { 'COUNT': 2 } ); // $ExpectError - curryRight( cxt.multiply, 2, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided more than three arguments... -{ - curryRight( ( x: number, y: number ): number => x + y, 2, {}, 4 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 76818ec..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 curryRight = require( './../lib' ); - -var fcn; -var out; -var i; - -function add( x, y, z, w, t, s ) { - return x + y + z + w + t + s; -} - -fcn = curryRight( add ); -out = fcn; -for ( i = 0; i < add.length; i++ ) { - out = out( i*10 ); -} -console.log( out ); 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..b4bb434 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@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 s(s,n,i){var o,l;if(!e(s))throw new TypeError(t("1SN3c",s));if(arguments.length<2){if(l=s.length,!r(l))throw new TypeError(t("1SNEX",l))}else if(arguments.length>2){if(o=i,!r(l=n))throw new TypeError(t("1SNAz",l))}else if(r(n))l=n;else{if(l=s.length,!r(l))throw new TypeError(t("1SNEX",l));o=n}return function e(r){return t;function t(t){var n=r.slice();return n.unshift(t),n.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNAz', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNEX', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","curried","v","cargs","slice","unshift","apply"],"mappings":";;kTAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,SAEjC,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAEjC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvCD,EAAUF,CACV,CACD,OASA,SAASU,EAAeC,GACvB,OAAOC,EASP,SAASA,EAASC,GACjB,IAAIC,EAAQH,EAAKI,QAEjB,OADAD,EAAME,QAASH,GACVC,EAAMN,OAASL,EACZO,EAAeI,GAEhBf,EAAIkB,MAAOf,EAASY,EAC3B,CACD,CA3BMJ,CAAe,GA4BvB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 7e7d2e8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform a function into a sequence of functions each accepting a single argument. -* -* @module @stdlib/utils-curry-right -* -* @example -* var curryRight = require( '@stdlib/utils-curry-right' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ - -// 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 ffb671a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* @param {Function} fcn - function to curry -* @param {PositiveInteger} [arity=fcn.length] - number of parameters -* @param {*} [thisArg] - evaluation context -* @throws {TypeError} first argument must be a function -* @throws {TypeError} first argument must be a function having at least one parameter -* @throws {TypeError} `arity` argument must be a positive integer -* @returns {Function} curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -function curryRight( fcn, arity, thisArg ) { - var context; - var len; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '1SN3c', fcn ) ); - } - if ( arguments.length < 2 ) { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNEX', len ) ); - } - } else if ( arguments.length > 2 ) { - len = arity; - context = thisArg; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNAz', len ) ); - } - } else if ( isPositiveInteger( arity ) ) { - len = arity; - } else { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNEX', len ) ); - } - context = arity; - } - return createCurried( [] ); - - /** - * Returns a curry function. - * - * @private - * @param {Array} args - arguments - * @returns {Function} curry function - */ - function createCurried( args ) { - return curried; - - /** - * Curry function. - * - * @private - * @param {*} v - curried function parameter - * @returns {(Function|*)} partially applied curry function or curried function result - */ - function curried( v ) { - var cargs = args.slice(); - cargs.unshift( v ); - if ( cargs.length < len ) { - return createCurried( cargs ); - } - return fcn.apply( context, cargs ); - } - } -} - - -// EXPORTS // - -module.exports = curryRight; diff --git a/package.json b/package.json index 5e700a4..f269d93 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Transform a function into a sequence of functions each accepting a single argument.", "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/assert-is-positive-integer": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/math-base-ops-add3": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/random-base-randu": "^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.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..5c63fa1 --- /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 3f1273f..0000000 --- a/test/test.js +++ /dev/null @@ -1,285 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var add = require( '@stdlib/math-base-ops-add3' ); -var curryRight = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof curryRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (1 arg)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (2 args; context)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an arity argument which is not a positive integer (3 args)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - 0, - -1, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( add, value, {} ); - }; - } -}); - -tape( 'the function returns a function', function test( t ) { - var fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function curries a function', function test( t) { - var fcn; - var f; - - fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'for each invocation where the invocation number is less than the arity, the curried function returns a new partially applied curry function', function test( t ) { - var sum; - var f0; - var f1; - var f2; - - // Initial curried function has no partially applied arguments... - f0 = curryRight( add ); - - sum = f0( 1 )( 2 )( 3 ); - t.strictEqual( sum, 6, 'returns 6' ); - - sum = f0( 1 )( 3 )( 5 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f0( 10 )( 20 )( 40 ); - t.strictEqual( sum, 70, 'returns 70' ); - - // If arity greater than 1, first invocation returns a curried function with one partially applied argument... - f1 = f0( 2 ); - - sum = f1( 3 )( 4 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f1( 10 )( 20 ); - t.strictEqual( sum, 32, 'returns 32' ); - - sum = f1( -1 )( -2 ); - t.strictEqual( sum, -1, 'returns -1' ); - - // If arity greater than 2, second invocation returns a curried function with two partially applied arguments... - f2 = f1( 3 ); - - sum = f2( 5 ); - t.strictEqual( sum, 10, 'returns 10' ); - - sum = f2( 6 ); - t.strictEqual( sum, 11, 'returns 11' ); - - sum = f2( 10 ); - t.strictEqual( sum, 15, 'returns 15' ); - - // And so on and so forth... - - t.end(); -}); - -tape( 'the function supports specifying a function arity', function test( t ) { - var fcn; - var f; - - function add() { - return arguments[ 0 ] + arguments[ 1 ] + arguments[ 2 ]; - } - - fcn = curryRight( add, 3 ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'the function supports specifying a function context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate( length, units, type, color ) { - return this.style+': '+length+units+' '+type+' '+color; - } - }; - - fcn = curryRight( context.generate, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); - -tape( 'the function supports specifying a function arity and context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate() { - return this.style+': '+arguments[0]+arguments[1]+' '+arguments[2]+' '+arguments[3]; - } - }; - - fcn = curryRight( context.generate, 4, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); From 90c069ffdc859fe02be47021226b9f515a6a7df9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 24 Dec 2024 20:37:19 +0000 Subject: [PATCH 130/140] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index 8d7768e..ffb671a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -52,25 +52,25 @@ function curryRight( fcn, arity, thisArg ) { var context; var len; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '1SN3c', fcn ) ); } if ( arguments.length < 2 ) { len = fcn.length; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); + throw new TypeError( format( '1SNEX', len ) ); } } else if ( arguments.length > 2 ) { len = arity; context = thisArg; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) ); + throw new TypeError( format( '1SNAz', len ) ); } } else if ( isPositiveInteger( arity ) ) { len = arity; } else { len = fcn.length; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); + throw new TypeError( format( '1SNEX', len ) ); } context = arity; } diff --git a/package.json b/package.json index d433a32..5e700a4 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-function": "^0.2.2", "@stdlib/assert-is-positive-integer": "^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 d046e1b058e24249ea9259ce762f8515171211d9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 24 Dec 2024 20:53:05 +0000 Subject: [PATCH 131/140] Remove files --- index.d.ts | 116 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4963 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 5a84dff..0000000 --- a/index.d.ts +++ /dev/null @@ -1,116 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Utility type to reverse a tuple type. -*/ -type ReverseTuple> = T extends [infer First, ...infer Rest] ? [...ReverseTuple, First] : []; // eslint-disable-line @typescript-eslint/no-explicit-any - -/** -* Curry function type for curryRight. -*/ -type CurryRightFunction< - TThis, - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn -> = ( this: TThis, ...args: TArgs ) => TReturn; - -/** -* Curry function. -* -* @param v - curried function parameter -* @returns partially applied curry function or curried function result -*/ -type Closure< - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn -> = ReverseTuple extends [infer TFirst, ...infer TRest] - ? ( v: TFirst ) => Closure, TReturn> - : TReturn; - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param arity - number of parameters -* @param thisArg - evaluation context -* @throws `arity` must be a positive integer -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight< - TThis extends object, - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn ->( - fcn: CurryRightFunction, - arity: number, - thisArg?: TThis -): Closure; - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param thisArg - evaluation context -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight< - TThis extends object, - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn ->( - fcn: CurryRightFunction, - thisArg?: TThis -): Closure; - - -// EXPORTS // - -export = curryRight; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b4bb434..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@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 s(s,n,i){var o,l;if(!e(s))throw new TypeError(t("1SN3c",s));if(arguments.length<2){if(l=s.length,!r(l))throw new TypeError(t("1SNEX",l))}else if(arguments.length>2){if(o=i,!r(l=n))throw new TypeError(t("1SNAz",l))}else if(r(n))l=n;else{if(l=s.length,!r(l))throw new TypeError(t("1SNEX",l));o=n}return function e(r){return t;function t(t){var n=r.slice();return n.unshift(t),n.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNAz', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNEX', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","curried","v","cargs","slice","unshift","apply"],"mappings":";;kTAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,SAEjC,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAEjC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvCD,EAAUF,CACV,CACD,OASA,SAASU,EAAeC,GACvB,OAAOC,EASP,SAASA,EAASC,GACjB,IAAIC,EAAQH,EAAKI,QAEjB,OADAD,EAAME,QAASH,GACVC,EAAMN,OAASL,EACZO,EAAeI,GAEhBf,EAAIkB,MAAOf,EAASY,EAC3B,CACD,CA3BMJ,CAAe,GA4BvB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 5c63fa1..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 754246503bb4db81159f3289a9989dec9d9bfc76 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 24 Dec 2024 20:53:20 +0000 Subject: [PATCH 132/140] 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 - .github/workflows/test_published_package.yml | 105 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 243 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 41 +- SECURITY.md | 5 - benchmark/benchmark.js | 90 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 53 - docs/types/test.ts | 71 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 110 - package.json | 57 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 285 -- 43 files changed, 4865 insertions(+), 4403 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (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 0779e8a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2b7fad0..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/curry-right) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 9ffcfa1..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/curry-right) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 906f5af..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: '6 18 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f4575e9..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -260,7 +251,7 @@ console.log( out ); ## 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]. @@ -325,11 +316,11 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry +[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry/tree/esm -[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry +[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry/tree/esm -[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right +[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right/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 69ca868..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isFunction = require( '@stdlib/assert-is-function' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var curryRight = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = curryRight( pow ); - if ( typeof out !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( out ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::returned_function', function benchmark( b ) { - var fcn; - var out; - var i; - - fcn = curryRight( pow ); - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = fcn( randu() )( randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::direct', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = pow( randu(), randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 7ef3db2..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/curry-right" -%% click B href "https://github.com/stdlib-js/utils-curry-right/tree/main" -%% click C href "https://github.com/stdlib-js/utils-curry-right/tree/production" -%% click D href "https://github.com/stdlib-js/utils-curry-right/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-curry-right/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-curry-right/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/curry-right -[production-url]: https://github.com/stdlib-js/utils-curry-right/tree/production -[deno-url]: https://github.com/stdlib-js/utils-curry-right/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-curry-right/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-curry-right/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-curry-right/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-curry-right/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-curry-right/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 8166962..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import curryRight from '../docs/types/index'; -export = curryRight; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 16477e0..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var g=f(function(b,o){ -var c=require('@stdlib/assert-is-function/dist'),n=require('@stdlib/assert-is-positive-integer/dist').isPrimitive,a=require('@stdlib/error-tools-fmtprodmsg/dist');function p(t,r,l){var u,e;if(!c(t))throw new TypeError(a('1SN3c',t));if(arguments.length<2){if(e=t.length,!n(e))throw new TypeError(a('1SNEX',e))}else if(arguments.length>2){if(e=r,u=l,!n(e))throw new TypeError(a('1SNAz',e))}else if(n(r))e=r;else{if(e=t.length,!n(e))throw new TypeError(a('1SNEX',e));u=r}return s([]);function s(m){return v;function v(h){var i=m.slice();return i.unshift(h),i.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = curryRight;\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* Transform a function into a sequence of functions each accepting a single argument.\n*\n* @module @stdlib/utils-curry-right\n*\n* @example\n* var curryRight = require( '@stdlib/utils-curry-right' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var f = curryRight( add );\n*\n* var sum = f( 2 )( 3 );\n* // returns 5\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,EAAoB,QAAS,oCAAqC,EAAE,YACpEC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,EAAYC,EAAKC,EAAOC,EAAU,CAC1C,IAAIC,EACAC,EACJ,GAAK,CAACR,EAAYI,CAAI,EACrB,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAI,CAAE,EAEzG,GAAK,UAAU,OAAS,GAEvB,GADAI,EAAMJ,EAAI,OACL,CAACH,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,kGAAmGM,CAAI,CAAE,UAE5H,UAAU,OAAS,GAG9B,GAFAA,EAAMH,EACNE,EAAUD,EACL,CAACL,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,4EAA6EM,CAAI,CAAE,UAEtGP,EAAmBI,CAAM,EACpCG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAI,OACL,CAACH,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,kGAAmGM,CAAI,CAAE,EAEvID,EAAUF,CACX,CACA,OAAOI,EAAe,CAAC,CAAE,EASzB,SAASA,EAAeC,EAAO,CAC9B,OAAOC,EASP,SAASA,EAASC,EAAI,CACrB,IAAIC,EAAQH,EAAK,MAAM,EAEvB,OADAG,EAAM,QAASD,CAAE,EACZC,EAAM,OAASL,EACZC,EAAeI,CAAM,EAEtBT,EAAI,MAAOG,EAASM,CAAM,CAClC,CACD,CACD,CAKAd,EAAO,QAAUI,ICrEjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isPositiveInteger", "format", "curryRight", "fcn", "arity", "thisArg", "context", "len", "createCurried", "args", "curried", "v", "cargs", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7271aed..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,53 +0,0 @@ - -{{alias}}( fcn[, arity][, thisArg] ) - Transforms a function into a sequence of functions each accepting a single - argument. - - Until return value resolution, each invocation returns a new partially - applied curry function. - - This function applies arguments starting from the right. - - Parameters - ---------- - fcn: Function - Function to curry. - - arity: integer (optional) - Number of parameters. Default: `fcn.length`. - - thisArg: any (optional) - Evaluation context. - - Returns - ------- - out: Function - Curry function. - - Examples - -------- - > function add( x, y ) { return x + y; }; - > var f = {{alias}}( add ); - > var sum = f( 2 )( 3 ) - 5 - - // Supply arity: - > function add() { return arguments[ 0 ] + arguments[ 1 ]; }; - > f = {{alias}}( add, 2 ); - > sum = f( 2 )( 3 ) - 5 - - // Provide function context: - > var obj = { - ... 'name': 'Ada', - ... 'greet': function greet( word1, word2 ) { - ... return word1 + ' ' + word2 + ', ' + this.name + '!' - ... } - ... }; - > f = {{alias}}( obj.greet, obj ); - > var str = f( 'there' )( 'Hello' ) - 'Hello there, Ada!' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4577cdb..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,71 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import curryRight = require( './index' ); - - -// TESTS // - -// The function returns a function... -{ - curryRight( ( x: number, y: number ): number => x + y ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: number, y: number ): number => x + y, 2 ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: number, y: number ): number => x + y, 2, {} ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: string, y: string ): string => x + y, {} ); // $ExpectType (v: string) => (v: string) => string - curryRight( ( x: string, y: string ): string => x + y, 2, {} ); // $ExpectType (v: string) => (v: string) => string - curryRight( ( str: string, n: number ): string => str.substring( n ) ); // $ExpectType (v: number) => (v: string) => string - - const cxt = { - 'count': 0, - 'multiply': function multiply( this: { count: number }, x: number, y: number ): number { - this.count += 1; // eslint-disable-line no-invalid-this - return x * y; - } - }; - curryRight( cxt.multiply ); // $ExpectType (v: number) => (v: number) => number - curryRight( cxt.multiply, 2 ); // $ExpectType (v: number) => (v: number) => number - curryRight( cxt.multiply, 2, { 'count': 2 } ); // $ExpectType (v: number) => (v: number) => number -} - -// The compiler throws an error if the function is provided a first argument other than a function... -{ - curryRight( true ); // $ExpectError - curryRight( false ); // $ExpectError - curryRight( 5 ); // $ExpectError - curryRight( [] ); // $ExpectError - curryRight( {} ); // $ExpectError - curryRight( 'abc' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a this argument which does not constitute a valid `this` context... -{ - const cxt = { - 'count': 0, - 'multiply': function multiply( this: { count: number }, x: number, y: number ): number { - this.count += 1; // eslint-disable-line no-invalid-this - return x * y; - } - }; - curryRight( cxt.multiply, { 'COUNT': 2 } ); // $ExpectError - curryRight( cxt.multiply, 2, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided more than three arguments... -{ - curryRight( ( x: number, y: number ): number => x + y, 2, {}, 4 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 76818ec..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 curryRight = require( './../lib' ); - -var fcn; -var out; -var i; - -function add( x, y, z, w, t, s ) { - return x + y + z + w + t + s; -} - -fcn = curryRight( add ); -out = fcn; -for ( i = 0; i < add.length; i++ ) { - out = out( i*10 ); -} -console.log( out ); 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..b4bb434 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@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 s(s,n,i){var o,l;if(!e(s))throw new TypeError(t("1SN3c",s));if(arguments.length<2){if(l=s.length,!r(l))throw new TypeError(t("1SNEX",l))}else if(arguments.length>2){if(o=i,!r(l=n))throw new TypeError(t("1SNAz",l))}else if(r(n))l=n;else{if(l=s.length,!r(l))throw new TypeError(t("1SNEX",l));o=n}return function e(r){return t;function t(t){var n=r.slice();return n.unshift(t),n.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNAz', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNEX', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","curried","v","cargs","slice","unshift","apply"],"mappings":";;kTAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,SAEjC,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAEjC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvCD,EAAUF,CACV,CACD,OASA,SAASU,EAAeC,GACvB,OAAOC,EASP,SAASA,EAASC,GACjB,IAAIC,EAAQH,EAAKI,QAEjB,OADAD,EAAME,QAASH,GACVC,EAAMN,OAASL,EACZO,EAAeI,GAEhBf,EAAIkB,MAAOf,EAASY,EAC3B,CACD,CA3BMJ,CAAe,GA4BvB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 7e7d2e8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform a function into a sequence of functions each accepting a single argument. -* -* @module @stdlib/utils-curry-right -* -* @example -* var curryRight = require( '@stdlib/utils-curry-right' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ - -// 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 ffb671a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* @param {Function} fcn - function to curry -* @param {PositiveInteger} [arity=fcn.length] - number of parameters -* @param {*} [thisArg] - evaluation context -* @throws {TypeError} first argument must be a function -* @throws {TypeError} first argument must be a function having at least one parameter -* @throws {TypeError} `arity` argument must be a positive integer -* @returns {Function} curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -function curryRight( fcn, arity, thisArg ) { - var context; - var len; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '1SN3c', fcn ) ); - } - if ( arguments.length < 2 ) { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNEX', len ) ); - } - } else if ( arguments.length > 2 ) { - len = arity; - context = thisArg; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNAz', len ) ); - } - } else if ( isPositiveInteger( arity ) ) { - len = arity; - } else { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNEX', len ) ); - } - context = arity; - } - return createCurried( [] ); - - /** - * Returns a curry function. - * - * @private - * @param {Array} args - arguments - * @returns {Function} curry function - */ - function createCurried( args ) { - return curried; - - /** - * Curry function. - * - * @private - * @param {*} v - curried function parameter - * @returns {(Function|*)} partially applied curry function or curried function result - */ - function curried( v ) { - var cargs = args.slice(); - cargs.unshift( v ); - if ( cargs.length < len ) { - return createCurried( cargs ); - } - return fcn.apply( context, cargs ); - } - } -} - - -// EXPORTS // - -module.exports = curryRight; diff --git a/package.json b/package.json index 5e700a4..f269d93 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Transform a function into a sequence of functions each accepting a single argument.", "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/assert-is-positive-integer": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/math-base-ops-add3": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/random-base-randu": "^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.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..5c63fa1 --- /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 5be0bb8..0000000 --- a/test/test.js +++ /dev/null @@ -1,285 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var add = require( '@stdlib/math-base-ops-add3' ); -var curryRight = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof curryRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (1 arg)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (2 args; context)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an arity argument which is not a positive integer (3 args)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - 0, - -1, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( add, value, {} ); - }; - } -}); - -tape( 'the function returns a function', function test( t ) { - var fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - t.end(); -}); - -tape( 'the function curries a function', function test( t ) { - var fcn; - var f; - - fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'for each invocation where the invocation number is less than the arity, the curried function returns a new partially applied curry function', function test( t ) { - var sum; - var f0; - var f1; - var f2; - - // Initial curried function has no partially applied arguments... - f0 = curryRight( add ); - - sum = f0( 1 )( 2 )( 3 ); - t.strictEqual( sum, 6, 'returns 6' ); - - sum = f0( 1 )( 3 )( 5 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f0( 10 )( 20 )( 40 ); - t.strictEqual( sum, 70, 'returns 70' ); - - // If arity greater than 1, first invocation returns a curried function with one partially applied argument... - f1 = f0( 2 ); - - sum = f1( 3 )( 4 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f1( 10 )( 20 ); - t.strictEqual( sum, 32, 'returns 32' ); - - sum = f1( -1 )( -2 ); - t.strictEqual( sum, -1, 'returns -1' ); - - // If arity greater than 2, second invocation returns a curried function with two partially applied arguments... - f2 = f1( 3 ); - - sum = f2( 5 ); - t.strictEqual( sum, 10, 'returns 10' ); - - sum = f2( 6 ); - t.strictEqual( sum, 11, 'returns 11' ); - - sum = f2( 10 ); - t.strictEqual( sum, 15, 'returns 15' ); - - // And so on and so forth... - - t.end(); -}); - -tape( 'the function supports specifying a function arity', function test( t ) { - var fcn; - var f; - - function add() { - return arguments[ 0 ] + arguments[ 1 ] + arguments[ 2 ]; - } - - fcn = curryRight( add, 3 ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'the function supports specifying a function context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate( length, units, type, color ) { - return this.style+': '+length+units+' '+type+' '+color; - } - }; - - fcn = curryRight( context.generate, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); - -tape( 'the function supports specifying a function arity and context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate() { - return this.style+': '+arguments[0]+arguments[1]+' '+arguments[2]+' '+arguments[3]; - } - }; - - fcn = curryRight( context.generate, 4, context ); - t.strictEqual( typeof fcn, 'function', 'returns a function' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns a function' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); From fe1c3c1a7c88a3a601ea8644078259852fd93f69 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 29 Jan 2026 22:25:09 +0000 Subject: [PATCH 133/140] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index 8d7768e..ffb671a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -52,25 +52,25 @@ function curryRight( fcn, arity, thisArg ) { var context; var len; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '1SN3c', fcn ) ); } if ( arguments.length < 2 ) { len = fcn.length; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); + throw new TypeError( format( '1SNEX', len ) ); } } else if ( arguments.length > 2 ) { len = arity; context = thisArg; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) ); + throw new TypeError( format( '1SNAz', len ) ); } } else if ( isPositiveInteger( arity ) ) { len = arity; } else { len = fcn.length; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); + throw new TypeError( format( '1SNEX', len ) ); } context = arity; } diff --git a/package.json b/package.json index a29faa0..9f7c505 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-function": "^0.2.2", "@stdlib/assert-is-positive-integer": "^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 08b8fd958cd7501af745e46f43ceb2304e075918 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 29 Jan 2026 23:15:15 +0000 Subject: [PATCH 134/140] Remove files --- index.d.ts | 116 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4963 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 5a84dff..0000000 --- a/index.d.ts +++ /dev/null @@ -1,116 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Utility type to reverse a tuple type. -*/ -type ReverseTuple> = T extends [infer First, ...infer Rest] ? [...ReverseTuple, First] : []; // eslint-disable-line @typescript-eslint/no-explicit-any - -/** -* Curry function type for curryRight. -*/ -type CurryRightFunction< - TThis, - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn -> = ( this: TThis, ...args: TArgs ) => TReturn; - -/** -* Curry function. -* -* @param v - curried function parameter -* @returns partially applied curry function or curried function result -*/ -type Closure< - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn -> = ReverseTuple extends [infer TFirst, ...infer TRest] - ? ( v: TFirst ) => Closure, TReturn> - : TReturn; - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param arity - number of parameters -* @param thisArg - evaluation context -* @throws `arity` must be a positive integer -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight< - TThis extends object, - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn ->( - fcn: CurryRightFunction, - arity: number, - thisArg?: TThis -): Closure; - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param thisArg - evaluation context -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight< - TThis extends object, - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn ->( - fcn: CurryRightFunction, - thisArg?: TThis -): Closure; - - -// EXPORTS // - -export = curryRight; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b4bb434..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@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 s(s,n,i){var o,l;if(!e(s))throw new TypeError(t("1SN3c",s));if(arguments.length<2){if(l=s.length,!r(l))throw new TypeError(t("1SNEX",l))}else if(arguments.length>2){if(o=i,!r(l=n))throw new TypeError(t("1SNAz",l))}else if(r(n))l=n;else{if(l=s.length,!r(l))throw new TypeError(t("1SNEX",l));o=n}return function e(r){return t;function t(t){var n=r.slice();return n.unshift(t),n.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNAz', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNEX', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","curried","v","cargs","slice","unshift","apply"],"mappings":";;kTAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,SAEjC,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAEjC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvCD,EAAUF,CACV,CACD,OASA,SAASU,EAAeC,GACvB,OAAOC,EASP,SAASA,EAASC,GACjB,IAAIC,EAAQH,EAAKI,QAEjB,OADAD,EAAME,QAASH,GACVC,EAAMN,OAASL,EACZO,EAAeI,GAEhBf,EAAIkB,MAAOf,EAASY,EAC3B,CACD,CA3BMJ,CAAe,GA4BvB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 5c63fa1..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From ca58f399a7b2e12923610ca1e791e14678c6d2e6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 29 Jan 2026 23:15:41 +0000 Subject: [PATCH 135/140] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 108 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 246 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 41 +- SECURITY.md | 5 - benchmark/benchmark.js | 90 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 53 - docs/types/test.ts | 71 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 110 - package.json | 57 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 285 -- 43 files changed, 4865 insertions(+), 4514 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (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/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index c0137f3..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/curry-right) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 9ffcfa1..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/curry-right) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 906f5af..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: '6 18 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -260,7 +251,7 @@ console.log( out ); ## 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]. @@ -325,11 +316,11 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry +[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry/tree/esm -[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry +[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry/tree/esm -[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right +[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right/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 69ca868..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isFunction = require( '@stdlib/assert-is-function' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var curryRight = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = curryRight( pow ); - if ( typeof out !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( out ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::returned_function', function benchmark( b ) { - var fcn; - var out; - var i; - - fcn = curryRight( pow ); - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = fcn( randu() )( randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::direct', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = pow( randu(), randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 7ef3db2..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/curry-right" -%% click B href "https://github.com/stdlib-js/utils-curry-right/tree/main" -%% click C href "https://github.com/stdlib-js/utils-curry-right/tree/production" -%% click D href "https://github.com/stdlib-js/utils-curry-right/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-curry-right/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-curry-right/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/curry-right -[production-url]: https://github.com/stdlib-js/utils-curry-right/tree/production -[deno-url]: https://github.com/stdlib-js/utils-curry-right/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-curry-right/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-curry-right/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-curry-right/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-curry-right/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-curry-right/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 8166962..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import curryRight from '../docs/types/index'; -export = curryRight; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 16477e0..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var g=f(function(b,o){ -var c=require('@stdlib/assert-is-function/dist'),n=require('@stdlib/assert-is-positive-integer/dist').isPrimitive,a=require('@stdlib/error-tools-fmtprodmsg/dist');function p(t,r,l){var u,e;if(!c(t))throw new TypeError(a('1SN3c',t));if(arguments.length<2){if(e=t.length,!n(e))throw new TypeError(a('1SNEX',e))}else if(arguments.length>2){if(e=r,u=l,!n(e))throw new TypeError(a('1SNAz',e))}else if(n(r))e=r;else{if(e=t.length,!n(e))throw new TypeError(a('1SNEX',e));u=r}return s([]);function s(m){return v;function v(h){var i=m.slice();return i.unshift(h),i.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = curryRight;\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* Transform a function into a sequence of functions each accepting a single argument.\n*\n* @module @stdlib/utils-curry-right\n*\n* @example\n* var curryRight = require( '@stdlib/utils-curry-right' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var f = curryRight( add );\n*\n* var sum = f( 2 )( 3 );\n* // returns 5\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,EAAoB,QAAS,oCAAqC,EAAE,YACpEC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,EAAYC,EAAKC,EAAOC,EAAU,CAC1C,IAAIC,EACAC,EACJ,GAAK,CAACR,EAAYI,CAAI,EACrB,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAI,CAAE,EAEzG,GAAK,UAAU,OAAS,GAEvB,GADAI,EAAMJ,EAAI,OACL,CAACH,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,kGAAmGM,CAAI,CAAE,UAE5H,UAAU,OAAS,GAG9B,GAFAA,EAAMH,EACNE,EAAUD,EACL,CAACL,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,4EAA6EM,CAAI,CAAE,UAEtGP,EAAmBI,CAAM,EACpCG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAI,OACL,CAACH,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,kGAAmGM,CAAI,CAAE,EAEvID,EAAUF,CACX,CACA,OAAOI,EAAe,CAAC,CAAE,EASzB,SAASA,EAAeC,EAAO,CAC9B,OAAOC,EASP,SAASA,EAASC,EAAI,CACrB,IAAIC,EAAQH,EAAK,MAAM,EAEvB,OADAG,EAAM,QAASD,CAAE,EACZC,EAAM,OAASL,EACZC,EAAeI,CAAM,EAEtBT,EAAI,MAAOG,EAASM,CAAM,CAClC,CACD,CACD,CAKAd,EAAO,QAAUI,ICrEjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isPositiveInteger", "format", "curryRight", "fcn", "arity", "thisArg", "context", "len", "createCurried", "args", "curried", "v", "cargs", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7271aed..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,53 +0,0 @@ - -{{alias}}( fcn[, arity][, thisArg] ) - Transforms a function into a sequence of functions each accepting a single - argument. - - Until return value resolution, each invocation returns a new partially - applied curry function. - - This function applies arguments starting from the right. - - Parameters - ---------- - fcn: Function - Function to curry. - - arity: integer (optional) - Number of parameters. Default: `fcn.length`. - - thisArg: any (optional) - Evaluation context. - - Returns - ------- - out: Function - Curry function. - - Examples - -------- - > function add( x, y ) { return x + y; }; - > var f = {{alias}}( add ); - > var sum = f( 2 )( 3 ) - 5 - - // Supply arity: - > function add() { return arguments[ 0 ] + arguments[ 1 ]; }; - > f = {{alias}}( add, 2 ); - > sum = f( 2 )( 3 ) - 5 - - // Provide function context: - > var obj = { - ... 'name': 'Ada', - ... 'greet': function greet( word1, word2 ) { - ... return word1 + ' ' + word2 + ', ' + this.name + '!' - ... } - ... }; - > f = {{alias}}( obj.greet, obj ); - > var str = f( 'there' )( 'Hello' ) - 'Hello there, Ada!' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4577cdb..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,71 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import curryRight = require( './index' ); - - -// TESTS // - -// The function returns a function... -{ - curryRight( ( x: number, y: number ): number => x + y ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: number, y: number ): number => x + y, 2 ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: number, y: number ): number => x + y, 2, {} ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: string, y: string ): string => x + y, {} ); // $ExpectType (v: string) => (v: string) => string - curryRight( ( x: string, y: string ): string => x + y, 2, {} ); // $ExpectType (v: string) => (v: string) => string - curryRight( ( str: string, n: number ): string => str.substring( n ) ); // $ExpectType (v: number) => (v: string) => string - - const cxt = { - 'count': 0, - 'multiply': function multiply( this: { count: number }, x: number, y: number ): number { - this.count += 1; // eslint-disable-line no-invalid-this - return x * y; - } - }; - curryRight( cxt.multiply ); // $ExpectType (v: number) => (v: number) => number - curryRight( cxt.multiply, 2 ); // $ExpectType (v: number) => (v: number) => number - curryRight( cxt.multiply, 2, { 'count': 2 } ); // $ExpectType (v: number) => (v: number) => number -} - -// The compiler throws an error if the function is provided a first argument other than a function... -{ - curryRight( true ); // $ExpectError - curryRight( false ); // $ExpectError - curryRight( 5 ); // $ExpectError - curryRight( [] ); // $ExpectError - curryRight( {} ); // $ExpectError - curryRight( 'abc' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a this argument which does not constitute a valid `this` context... -{ - const cxt = { - 'count': 0, - 'multiply': function multiply( this: { count: number }, x: number, y: number ): number { - this.count += 1; // eslint-disable-line no-invalid-this - return x * y; - } - }; - curryRight( cxt.multiply, { 'COUNT': 2 } ); // $ExpectError - curryRight( cxt.multiply, 2, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided more than three arguments... -{ - curryRight( ( x: number, y: number ): number => x + y, 2, {}, 4 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 76818ec..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 curryRight = require( './../lib' ); - -var fcn; -var out; -var i; - -function add( x, y, z, w, t, s ) { - return x + y + z + w + t + s; -} - -fcn = curryRight( add ); -out = fcn; -for ( i = 0; i < add.length; i++ ) { - out = out( i*10 ); -} -console.log( out ); 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..6073959 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@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 s(s,n,i){var o,l;if(!e(s))throw new TypeError(t("1SN3c",s));if(arguments.length<2){if(l=s.length,!r(l))throw new TypeError(t("1SNEX",l))}else if(arguments.length>2){if(o=i,!r(l=n))throw new TypeError(t("1SNAz",l))}else if(r(n))l=n;else{if(l=s.length,!r(l))throw new TypeError(t("1SNEX",l));o=n}return function e(r){return t;function t(t){var n=r.slice();return n.unshift(t),n.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNAz', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNEX', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","curried","v","cargs","slice","unshift","apply"],"mappings":";;kTAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,SAEjC,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAEjC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvCD,EAAUF,CACV,CACD,OASA,SAASU,EAAeC,GACvB,OAAOC,EASP,SAASA,EAASC,GACjB,IAAIC,EAAQH,EAAKI,QAEjB,OADAD,EAAME,QAASH,GACVC,EAAMN,OAASL,EACZO,EAAeI,GAEhBf,EAAIkB,MAAOf,EAASY,EAC3B,CACD,CA3BMJ,CAAe,GA4BvB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 7e7d2e8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform a function into a sequence of functions each accepting a single argument. -* -* @module @stdlib/utils-curry-right -* -* @example -* var curryRight = require( '@stdlib/utils-curry-right' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ - -// 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 ffb671a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* @param {Function} fcn - function to curry -* @param {PositiveInteger} [arity=fcn.length] - number of parameters -* @param {*} [thisArg] - evaluation context -* @throws {TypeError} first argument must be a function -* @throws {TypeError} first argument must be a function having at least one parameter -* @throws {TypeError} `arity` argument must be a positive integer -* @returns {Function} curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -function curryRight( fcn, arity, thisArg ) { - var context; - var len; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '1SN3c', fcn ) ); - } - if ( arguments.length < 2 ) { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNEX', len ) ); - } - } else if ( arguments.length > 2 ) { - len = arity; - context = thisArg; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNAz', len ) ); - } - } else if ( isPositiveInteger( arity ) ) { - len = arity; - } else { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNEX', len ) ); - } - context = arity; - } - return createCurried( [] ); - - /** - * Returns a curry function. - * - * @private - * @param {Array} args - arguments - * @returns {Function} curry function - */ - function createCurried( args ) { - return curried; - - /** - * Curry function. - * - * @private - * @param {*} v - curried function parameter - * @returns {(Function|*)} partially applied curry function or curried function result - */ - function curried( v ) { - var cargs = args.slice(); - cargs.unshift( v ); - if ( cargs.length < len ) { - return createCurried( cargs ); - } - return fcn.apply( context, cargs ); - } - } -} - - -// EXPORTS // - -module.exports = curryRight; diff --git a/package.json b/package.json index 9f7c505..f269d93 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Transform a function into a sequence of functions each accepting a single argument.", "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/assert-is-positive-integer": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/number-float64-base-add3": "^0.1.0", - "@stdlib/random-base-randu": "^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.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..5c63fa1 --- /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 e2175ce..0000000 --- a/test/test.js +++ /dev/null @@ -1,285 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var add = require( '@stdlib/number-float64-base-add3' ); -var curryRight = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof curryRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (1 arg)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (2 args; context)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an arity argument which is not a positive integer (3 args)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - 0, - -1, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( add, value, {} ); - }; - } -}); - -tape( 'the function returns a function', function test( t ) { - var fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns expected value' ); - t.end(); -}); - -tape( 'the function curries a function', function test( t ) { - var fcn; - var f; - - fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns expected value' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns expected value' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns expected value' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'for each invocation where the invocation number is less than the arity, the curried function returns a new partially applied curry function', function test( t ) { - var sum; - var f0; - var f1; - var f2; - - // Initial curried function has no partially applied arguments... - f0 = curryRight( add ); - - sum = f0( 1 )( 2 )( 3 ); - t.strictEqual( sum, 6, 'returns 6' ); - - sum = f0( 1 )( 3 )( 5 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f0( 10 )( 20 )( 40 ); - t.strictEqual( sum, 70, 'returns 70' ); - - // If arity greater than 1, first invocation returns a curried function with one partially applied argument... - f1 = f0( 2 ); - - sum = f1( 3 )( 4 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f1( 10 )( 20 ); - t.strictEqual( sum, 32, 'returns 32' ); - - sum = f1( -1 )( -2 ); - t.strictEqual( sum, -1, 'returns -1' ); - - // If arity greater than 2, second invocation returns a curried function with two partially applied arguments... - f2 = f1( 3 ); - - sum = f2( 5 ); - t.strictEqual( sum, 10, 'returns 10' ); - - sum = f2( 6 ); - t.strictEqual( sum, 11, 'returns 11' ); - - sum = f2( 10 ); - t.strictEqual( sum, 15, 'returns 15' ); - - // And so on and so forth... - - t.end(); -}); - -tape( 'the function supports specifying a function arity', function test( t ) { - var fcn; - var f; - - function add() { - return arguments[ 0 ] + arguments[ 1 ] + arguments[ 2 ]; - } - - fcn = curryRight( add, 3 ); - t.strictEqual( typeof fcn, 'function', 'returns expected value' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns expected value' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns expected value' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'the function supports specifying a function context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate( length, units, type, color ) { - return this.style+': '+length+units+' '+type+' '+color; - } - }; - - fcn = curryRight( context.generate, context ); - t.strictEqual( typeof fcn, 'function', 'returns expected value' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns expected value' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns expected value' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns expected value' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); - -tape( 'the function supports specifying a function arity and context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate() { - return this.style+': '+arguments[0]+arguments[1]+' '+arguments[2]+' '+arguments[3]; - } - }; - - fcn = curryRight( context.generate, 4, context ); - t.strictEqual( typeof fcn, 'function', 'returns expected value' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns expected value' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns expected value' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns expected value' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); From f9125e22ce6735a21a4f86356bf56d8325f92ef8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 7 Feb 2026 20:55:51 +0000 Subject: [PATCH 136/140] Transform error messages --- lib/main.js | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/main.js b/lib/main.js index 8d7768e..ffb671a 100644 --- a/lib/main.js +++ b/lib/main.js @@ -22,7 +22,7 @@ var isFunction = require( '@stdlib/assert-is-function' ); var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -52,25 +52,25 @@ function curryRight( fcn, arity, thisArg ) { var context; var len; if ( !isFunction( fcn ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) ); + throw new TypeError( format( '1SN3c', fcn ) ); } if ( arguments.length < 2 ) { len = fcn.length; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); + throw new TypeError( format( '1SNEX', len ) ); } } else if ( arguments.length > 2 ) { len = arity; context = thisArg; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) ); + throw new TypeError( format( '1SNAz', len ) ); } } else if ( isPositiveInteger( arity ) ) { len = arity; } else { len = fcn.length; if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) ); + throw new TypeError( format( '1SNEX', len ) ); } context = arity; } diff --git a/package.json b/package.json index 32b66d5..c639839 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-function": "^0.2.3", "@stdlib/assert-is-positive-integer": "^0.2.3", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.3" }, "devDependencies": { From c4bbd7b8a60d2c047f516c954a4b6f35d7b25ba6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 7 Feb 2026 21:39:05 +0000 Subject: [PATCH 137/140] Remove files --- index.d.ts | 116 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4963 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 5a84dff..0000000 --- a/index.d.ts +++ /dev/null @@ -1,116 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/** -* Utility type to reverse a tuple type. -*/ -type ReverseTuple> = T extends [infer First, ...infer Rest] ? [...ReverseTuple, First] : []; // eslint-disable-line @typescript-eslint/no-explicit-any - -/** -* Curry function type for curryRight. -*/ -type CurryRightFunction< - TThis, - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn -> = ( this: TThis, ...args: TArgs ) => TReturn; - -/** -* Curry function. -* -* @param v - curried function parameter -* @returns partially applied curry function or curried function result -*/ -type Closure< - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn -> = ReverseTuple extends [infer TFirst, ...infer TRest] - ? ( v: TFirst ) => Closure, TReturn> - : TReturn; - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param arity - number of parameters -* @param thisArg - evaluation context -* @throws `arity` must be a positive integer -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight< - TThis extends object, - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn ->( - fcn: CurryRightFunction, - arity: number, - thisArg?: TThis -): Closure; - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* ## Notes -* -* - Until return value resolution, each invocation returns a new partially applied curry function. -* - This function applies arguments starting from the right. -* -* @param fcn - function to curry -* @param thisArg - evaluation context -* @returns curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -declare function curryRight< - TThis extends object, - TArgs extends Array, // eslint-disable-line @typescript-eslint/no-explicit-any - TReturn ->( - fcn: CurryRightFunction, - thisArg?: TThis -): Closure; - - -// EXPORTS // - -export = curryRight; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 6073959..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.2-esm/index.mjs";import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@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 s(s,n,i){var o,l;if(!e(s))throw new TypeError(t("1SN3c",s));if(arguments.length<2){if(l=s.length,!r(l))throw new TypeError(t("1SNEX",l))}else if(arguments.length>2){if(o=i,!r(l=n))throw new TypeError(t("1SNAz",l))}else if(r(n))l=n;else{if(l=s.length,!r(l))throw new TypeError(t("1SNEX",l));o=n}return function e(r){return t;function t(t){var n=r.slice();return n.unshift(t),n.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNAz', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNEX', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","curried","v","cargs","slice","unshift","apply"],"mappings":";;kTAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,SAEjC,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAEjC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvCD,EAAUF,CACV,CACD,OASA,SAASU,EAAeC,GACvB,OAAOC,EASP,SAASA,EAASC,GACjB,IAAIC,EAAQH,EAAKI,QAEjB,OADAD,EAAME,QAASH,GACVC,EAAMN,OAASL,EACZO,EAAeI,GAEhBf,EAAIkB,MAAOf,EAASY,EAC3B,CACD,CA3BMJ,CAAe,GA4BvB"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 5c63fa1..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From c1b68c2a28478982370c607188c9a4fdffaa05d8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 7 Feb 2026 21:39:21 +0000 Subject: [PATCH 138/140] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 246 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 41 +- SECURITY.md | 5 - benchmark/benchmark.js | 90 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 53 - docs/types/test.ts | 71 - examples/index.js | 36 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 46 - lib/main.js | 110 - package.json | 57 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 285 -- 43 files changed, 4865 insertions(+), 4507 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (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/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index c0137f3..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/curry-right) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 9ffcfa1..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/curry-right) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 906f5af..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: '6 18 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -260,7 +251,7 @@ console.log( out ); ## 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]. @@ -325,11 +316,11 @@ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors]. -[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry +[@stdlib/utils/curry]: https://github.com/stdlib-js/utils-curry/tree/esm -[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry +[@stdlib/utils/uncurry]: https://github.com/stdlib-js/utils-uncurry/tree/esm -[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right +[@stdlib/utils/uncurry-right]: https://github.com/stdlib-js/utils-uncurry-right/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 69ca868..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,90 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isFunction = require( '@stdlib/assert-is-function' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var pkg = require( './../package.json' ).name; -var curryRight = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = curryRight( pow ); - if ( typeof out !== 'function' ) { - b.fail( 'should return a function' ); - } - } - b.toc(); - if ( !isFunction( out ) ) { - b.fail( 'should return a function' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::returned_function', function benchmark( b ) { - var fcn; - var out; - var i; - - fcn = curryRight( pow ); - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = fcn( randu() )( randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::direct', function benchmark( b ) { - var out; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = pow( randu(), randu() ); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - if ( out !== out ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 7ef3db2..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/curry-right" -%% click B href "https://github.com/stdlib-js/utils-curry-right/tree/main" -%% click C href "https://github.com/stdlib-js/utils-curry-right/tree/production" -%% click D href "https://github.com/stdlib-js/utils-curry-right/tree/esm" -%% click E href "https://github.com/stdlib-js/utils-curry-right/tree/deno" -%% click F href "https://github.com/stdlib-js/utils-curry-right/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/curry-right -[production-url]: https://github.com/stdlib-js/utils-curry-right/tree/production -[deno-url]: https://github.com/stdlib-js/utils-curry-right/tree/deno -[deno-readme]: https://github.com/stdlib-js/utils-curry-right/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/utils-curry-right/tree/umd -[umd-readme]: https://github.com/stdlib-js/utils-curry-right/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/utils-curry-right/tree/esm -[esm-readme]: https://github.com/stdlib-js/utils-curry-right/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 8166962..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import curryRight from '../docs/types/index'; -export = curryRight; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 16477e0..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var f=function(t,r){return function(){return r||t((r={exports:{}}).exports,r),r.exports}};var g=f(function(b,o){ -var c=require('@stdlib/assert-is-function/dist'),n=require('@stdlib/assert-is-positive-integer/dist').isPrimitive,a=require('@stdlib/error-tools-fmtprodmsg/dist');function p(t,r,l){var u,e;if(!c(t))throw new TypeError(a('1SN3c',t));if(arguments.length<2){if(e=t.length,!n(e))throw new TypeError(a('1SNEX',e))}else if(arguments.length>2){if(e=r,u=l,!n(e))throw new TypeError(a('1SNAz',e))}else if(n(r))e=r;else{if(e=t.length,!n(e))throw new TypeError(a('1SNEX',e));u=r}return s([]);function s(m){return v;function v(h){var i=m.slice();return i.unshift(h),i.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Arity argument must be a positive integer. Value: `%s`.', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. First argument must be a function having at least one parameter. Value: `%s`.', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = curryRight;\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* Transform a function into a sequence of functions each accepting a single argument.\n*\n* @module @stdlib/utils-curry-right\n*\n* @example\n* var curryRight = require( '@stdlib/utils-curry-right' );\n*\n* function add( x, y ) {\n* return x + y;\n* }\n*\n* var f = curryRight( add );\n*\n* var sum = f( 2 )( 3 );\n* // returns 5\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,EAAoB,QAAS,oCAAqC,EAAE,YACpEC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,EAAYC,EAAKC,EAAOC,EAAU,CAC1C,IAAIC,EACAC,EACJ,GAAK,CAACR,EAAYI,CAAI,EACrB,MAAM,IAAI,UAAWF,EAAQ,oEAAqEE,CAAI,CAAE,EAEzG,GAAK,UAAU,OAAS,GAEvB,GADAI,EAAMJ,EAAI,OACL,CAACH,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,kGAAmGM,CAAI,CAAE,UAE5H,UAAU,OAAS,GAG9B,GAFAA,EAAMH,EACNE,EAAUD,EACL,CAACL,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,4EAA6EM,CAAI,CAAE,UAEtGP,EAAmBI,CAAM,EACpCG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAI,OACL,CAACH,EAAmBO,CAAI,EAC5B,MAAM,IAAI,UAAWN,EAAQ,kGAAmGM,CAAI,CAAE,EAEvID,EAAUF,CACX,CACA,OAAOI,EAAe,CAAC,CAAE,EASzB,SAASA,EAAeC,EAAO,CAC9B,OAAOC,EASP,SAASA,EAASC,EAAI,CACrB,IAAIC,EAAQH,EAAK,MAAM,EAEvB,OADAG,EAAM,QAASD,CAAE,EACZC,EAAM,OAASL,EACZC,EAAeI,CAAM,EAEtBT,EAAI,MAAOG,EAASM,CAAM,CAClC,CACD,CACD,CAKAd,EAAO,QAAUI,ICrEjB,IAAIW,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isPositiveInteger", "format", "curryRight", "fcn", "arity", "thisArg", "context", "len", "createCurried", "args", "curried", "v", "cargs", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 7271aed..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,53 +0,0 @@ - -{{alias}}( fcn[, arity][, thisArg] ) - Transforms a function into a sequence of functions each accepting a single - argument. - - Until return value resolution, each invocation returns a new partially - applied curry function. - - This function applies arguments starting from the right. - - Parameters - ---------- - fcn: Function - Function to curry. - - arity: integer (optional) - Number of parameters. Default: `fcn.length`. - - thisArg: any (optional) - Evaluation context. - - Returns - ------- - out: Function - Curry function. - - Examples - -------- - > function add( x, y ) { return x + y; }; - > var f = {{alias}}( add ); - > var sum = f( 2 )( 3 ) - 5 - - // Supply arity: - > function add() { return arguments[ 0 ] + arguments[ 1 ]; }; - > f = {{alias}}( add, 2 ); - > sum = f( 2 )( 3 ) - 5 - - // Provide function context: - > var obj = { - ... 'name': 'Ada', - ... 'greet': function greet( word1, word2 ) { - ... return word1 + ' ' + word2 + ', ' + this.name + '!' - ... } - ... }; - > f = {{alias}}( obj.greet, obj ); - > var str = f( 'there' )( 'Hello' ) - 'Hello there, Ada!' - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 4577cdb..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,71 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import curryRight = require( './index' ); - - -// TESTS // - -// The function returns a function... -{ - curryRight( ( x: number, y: number ): number => x + y ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: number, y: number ): number => x + y, 2 ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: number, y: number ): number => x + y, 2, {} ); // $ExpectType (v: number) => (v: number) => number - curryRight( ( x: string, y: string ): string => x + y, {} ); // $ExpectType (v: string) => (v: string) => string - curryRight( ( x: string, y: string ): string => x + y, 2, {} ); // $ExpectType (v: string) => (v: string) => string - curryRight( ( str: string, n: number ): string => str.substring( n ) ); // $ExpectType (v: number) => (v: string) => string - - const cxt = { - 'count': 0, - 'multiply': function multiply( this: { count: number }, x: number, y: number ): number { - this.count += 1; // eslint-disable-line no-invalid-this - return x * y; - } - }; - curryRight( cxt.multiply ); // $ExpectType (v: number) => (v: number) => number - curryRight( cxt.multiply, 2 ); // $ExpectType (v: number) => (v: number) => number - curryRight( cxt.multiply, 2, { 'count': 2 } ); // $ExpectType (v: number) => (v: number) => number -} - -// The compiler throws an error if the function is provided a first argument other than a function... -{ - curryRight( true ); // $ExpectError - curryRight( false ); // $ExpectError - curryRight( 5 ); // $ExpectError - curryRight( [] ); // $ExpectError - curryRight( {} ); // $ExpectError - curryRight( 'abc' ); // $ExpectError -} - -// The compiler throws an error if the function is provided a this argument which does not constitute a valid `this` context... -{ - const cxt = { - 'count': 0, - 'multiply': function multiply( this: { count: number }, x: number, y: number ): number { - this.count += 1; // eslint-disable-line no-invalid-this - return x * y; - } - }; - curryRight( cxt.multiply, { 'COUNT': 2 } ); // $ExpectError - curryRight( cxt.multiply, 2, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided more than three arguments... -{ - curryRight( ( x: number, y: number ): number => x + y, 2, {}, 4 ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 76818ec..0000000 --- a/examples/index.js +++ /dev/null @@ -1,36 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 curryRight = require( './../lib' ); - -var fcn; -var out; -var i; - -function add( x, y, z, w, t, s ) { - return x + y + z + w + t + s; -} - -fcn = curryRight( add ); -out = fcn; -for ( i = 0; i < add.length; i++ ) { - out = out( i*10 ); -} -console.log( out ); 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..e452062 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import e from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-function@v0.2.3-esm/index.mjs";import{isPrimitive as r}from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-positive-integer@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";function s(s,n,i){var o,l;if(!e(s))throw new TypeError(t("1SN3c",s));if(arguments.length<2){if(l=s.length,!r(l))throw new TypeError(t("1SNEX",l))}else if(arguments.length>2){if(o=i,!r(l=n))throw new TypeError(t("1SNAz",l))}else if(r(n))l=n;else{if(l=s.length,!r(l))throw new TypeError(t("1SNEX",l));o=n}return function e(r){return t;function t(t){var n=r.slice();return n.unshift(t),n.length 2 ) {\n\t\tlen = arity;\n\t\tcontext = thisArg;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNAz', len ) );\n\t\t}\n\t} else if ( isPositiveInteger( arity ) ) {\n\t\tlen = arity;\n\t} else {\n\t\tlen = fcn.length;\n\t\tif ( !isPositiveInteger( len ) ) {\n\t\t\tthrow new TypeError( format( '1SNEX', len ) );\n\t\t}\n\t\tcontext = arity;\n\t}\n\treturn createCurried( [] );\n\n\t/**\n\t* Returns a curry function.\n\t*\n\t* @private\n\t* @param {Array} args - arguments\n\t* @returns {Function} curry function\n\t*/\n\tfunction createCurried( args ) {\n\t\treturn curried;\n\n\t\t/**\n\t\t* Curry function.\n\t\t*\n\t\t* @private\n\t\t* @param {*} v - curried function parameter\n\t\t* @returns {(Function|*)} partially applied curry function or curried function result\n\t\t*/\n\t\tfunction curried( v ) {\n\t\t\tvar cargs = args.slice();\n\t\t\tcargs.unshift( v );\n\t\t\tif ( cargs.length < len ) {\n\t\t\t\treturn createCurried( cargs );\n\t\t\t}\n\t\t\treturn fcn.apply( context, cargs );\n\t\t}\n\t}\n}\n\n\n// EXPORTS //\n\nexport default curryRight;\n"],"names":["curryRight","fcn","arity","thisArg","context","len","isFunction","TypeError","format","arguments","length","isPositiveInteger","createCurried","args","curried","v","cargs","slice","unshift","apply"],"mappings":";;kTAkDA,SAASA,EAAYC,EAAKC,EAAOC,GAChC,IAAIC,EACAC,EACJ,IAAMC,EAAYL,GACjB,MAAM,IAAIM,UAAWC,EAAQ,QAASP,IAEvC,GAAKQ,UAAUC,OAAS,GAEvB,GADAL,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,SAEjC,GAAKI,UAAUC,OAAS,GAG9B,GADAN,EAAUD,GACJQ,EAFNN,EAAMH,GAGL,MAAM,IAAIK,UAAWC,EAAQ,QAASH,SAEjC,GAAKM,EAAmBT,GAC9BG,EAAMH,MACA,CAEN,GADAG,EAAMJ,EAAIS,QACJC,EAAmBN,GACxB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvCD,EAAUF,CACV,CACD,OASA,SAASU,EAAeC,GACvB,OAAOC,EASP,SAASA,EAASC,GACjB,IAAIC,EAAQH,EAAKI,QAEjB,OADAD,EAAME,QAASH,GACVC,EAAMN,OAASL,EACZO,EAAeI,GAEhBf,EAAIkB,MAAOf,EAASY,EAC3B,CACD,CA3BMJ,CAAe,GA4BvB"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 7e7d2e8..0000000 --- a/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Transform a function into a sequence of functions each accepting a single argument. -* -* @module @stdlib/utils-curry-right -* -* @example -* var curryRight = require( '@stdlib/utils-curry-right' ); -* -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ - -// 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 ffb671a..0000000 --- a/lib/main.js +++ /dev/null @@ -1,110 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive; -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Transforms a function into a sequence of functions each accepting a single argument. -* -* @param {Function} fcn - function to curry -* @param {PositiveInteger} [arity=fcn.length] - number of parameters -* @param {*} [thisArg] - evaluation context -* @throws {TypeError} first argument must be a function -* @throws {TypeError} first argument must be a function having at least one parameter -* @throws {TypeError} `arity` argument must be a positive integer -* @returns {Function} curry function -* -* @example -* function add( x, y ) { -* return x + y; -* } -* -* var f = curryRight( add ); -* -* var sum = f( 2 )( 3 ); -* // returns 5 -*/ -function curryRight( fcn, arity, thisArg ) { - var context; - var len; - if ( !isFunction( fcn ) ) { - throw new TypeError( format( '1SN3c', fcn ) ); - } - if ( arguments.length < 2 ) { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNEX', len ) ); - } - } else if ( arguments.length > 2 ) { - len = arity; - context = thisArg; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNAz', len ) ); - } - } else if ( isPositiveInteger( arity ) ) { - len = arity; - } else { - len = fcn.length; - if ( !isPositiveInteger( len ) ) { - throw new TypeError( format( '1SNEX', len ) ); - } - context = arity; - } - return createCurried( [] ); - - /** - * Returns a curry function. - * - * @private - * @param {Array} args - arguments - * @returns {Function} curry function - */ - function createCurried( args ) { - return curried; - - /** - * Curry function. - * - * @private - * @param {*} v - curried function parameter - * @returns {(Function|*)} partially applied curry function or curried function result - */ - function curried( v ) { - var cargs = args.slice(); - cargs.unshift( v ); - if ( cargs.length < len ) { - return createCurried( cargs ); - } - return fcn.apply( context, cargs ); - } - } -} - - -// EXPORTS // - -module.exports = curryRight; diff --git a/package.json b/package.json index c639839..e4e9576 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.3", "description": "Transform a function into a sequence of functions each accepting a single argument.", "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.3", - "@stdlib/assert-is-positive-integer": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/number-float64-base-add3": "^0.1.1", - "@stdlib/random-base-randu": "^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..29052d6 --- /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 e2175ce..0000000 --- a/test/test.js +++ /dev/null @@ -1,285 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var add = require( '@stdlib/number-float64-base-add3' ); -var curryRight = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof curryRight, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided a function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (1 arg)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value ); - }; - } -}); - -tape( 'the function throws an error if not provided a function having at least one parameter (2 args; context)', function test( t ) { - var values; - var i; - - values = [ - function noop() {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( value, {} ); - }; - } -}); - -tape( 'the function throws an error if provided an arity argument which is not a positive integer (3 args)', function test( t ) { - var values; - var i; - - values = [ - '5', - 3.14, - 0, - -1, - NaN, - null, - void 0, - true, - [], - {} - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - curryRight( add, value, {} ); - }; - } -}); - -tape( 'the function returns a function', function test( t ) { - var fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns expected value' ); - t.end(); -}); - -tape( 'the function curries a function', function test( t ) { - var fcn; - var f; - - fcn = curryRight( add ); - t.strictEqual( typeof fcn, 'function', 'returns expected value' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns expected value' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns expected value' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'for each invocation where the invocation number is less than the arity, the curried function returns a new partially applied curry function', function test( t ) { - var sum; - var f0; - var f1; - var f2; - - // Initial curried function has no partially applied arguments... - f0 = curryRight( add ); - - sum = f0( 1 )( 2 )( 3 ); - t.strictEqual( sum, 6, 'returns 6' ); - - sum = f0( 1 )( 3 )( 5 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f0( 10 )( 20 )( 40 ); - t.strictEqual( sum, 70, 'returns 70' ); - - // If arity greater than 1, first invocation returns a curried function with one partially applied argument... - f1 = f0( 2 ); - - sum = f1( 3 )( 4 ); - t.strictEqual( sum, 9, 'returns 9' ); - - sum = f1( 10 )( 20 ); - t.strictEqual( sum, 32, 'returns 32' ); - - sum = f1( -1 )( -2 ); - t.strictEqual( sum, -1, 'returns -1' ); - - // If arity greater than 2, second invocation returns a curried function with two partially applied arguments... - f2 = f1( 3 ); - - sum = f2( 5 ); - t.strictEqual( sum, 10, 'returns 10' ); - - sum = f2( 6 ); - t.strictEqual( sum, 11, 'returns 11' ); - - sum = f2( 10 ); - t.strictEqual( sum, 15, 'returns 15' ); - - // And so on and so forth... - - t.end(); -}); - -tape( 'the function supports specifying a function arity', function test( t ) { - var fcn; - var f; - - function add() { - return arguments[ 0 ] + arguments[ 1 ] + arguments[ 2 ]; - } - - fcn = curryRight( add, 3 ); - t.strictEqual( typeof fcn, 'function', 'returns expected value' ); - - f = fcn( 5 ); - t.strictEqual( typeof f, 'function', 'returns expected value' ); - - f = f( 4 ); - t.strictEqual( typeof f, 'function', 'returns expected value' ); - - f = f( 3 ); - t.strictEqual( f, 12, 'returns curried function result' ); - - t.end(); -}); - -tape( 'the function supports specifying a function context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate( length, units, type, color ) { - return this.style+': '+length+units+' '+type+' '+color; - } - }; - - fcn = curryRight( context.generate, context ); - t.strictEqual( typeof fcn, 'function', 'returns expected value' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns expected value' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns expected value' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns expected value' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); - -tape( 'the function supports specifying a function arity and context', function test( t ) { - var context; - var fcn; - var f; - - context = { - 'style': 'border', - 'generate': function generate() { - return this.style+': '+arguments[0]+arguments[1]+' '+arguments[2]+' '+arguments[3]; - } - }; - - fcn = curryRight( context.generate, 4, context ); - t.strictEqual( typeof fcn, 'function', 'returns expected value' ); - - f = fcn( 'steelblue' ); - t.strictEqual( typeof f, 'function', 'returns expected value' ); - - f = f( 'dashed' ); - t.strictEqual( typeof f, 'function', 'returns expected value' ); - - f = f( 'px' ); - t.strictEqual( typeof f, 'function', 'returns expected value' ); - - f = f( 2 ); - t.strictEqual( f, 'border: 2px dashed steelblue' ); - - t.end(); -}); From 827e73f11cd017e1d61bd040497d8ef1118598c3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 7 Feb 2026 22:00:46 +0000 Subject: [PATCH 139/140] Update README.md for ESM bundle v0.2.3 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3a9732c..8ffa205 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import curryRight from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-curry-right@esm/index.mjs'; +import curryRight from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-curry-right@v0.2.3-esm/index.mjs'; ``` #### curryRight( fcn\[, arity]\[, thisArg] ) @@ -192,7 +192,7 @@ var str = fcn( 'there' )( 'Hello' );