From f3406ffa72f001e5ecd45823604109c0f9ded948 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Apr 2022 01:38:52 +0000 Subject: [PATCH 001/113] Auto-generated commit 3eb6739b39546a8b3c1f312efce3e2140046cdc2 --- CONTRIBUTORS | 28 + LICENSE | 481 +++++++++ NOTICE | 1 + README.md | 281 ++++++ index.d.ts | 150 +++ index.mjs | 4 + index.mjs.map | 1 + package.json | 33 + stats.html | 2689 +++++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 3668 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..ddb3651 --- /dev/null +++ b/README.md @@ -0,0 +1,281 @@ + + +# Open + +[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] + +> Open a file. + + + +
+ +## Usage + + + +```javascript +import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@esm/index.mjs'; +``` + +#### open( path\[, flags\[, mode]], clbk ) + +Asynchronously opens a file. + + + +```javascript +var closeSync = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-close' ).sync; + +open( __filename, onOpen ); + +function onOpen( error, fd ) { + if ( error ) { + console.error( error.message ); + } else { + closeSync( fd ); + } +} +``` + +The function has the same default parameter values as [`fs.open()`][node-fs]. + +#### open.sync( file\[, flags\[, mode]] ) + +Synchronously opens a `file`. + + + +```javascript +var closeSync = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-close' ).sync; + +var fd = open.sync( __filename ); +if ( fd instanceof Error ) { + console.error( fd.message ); +} else { + closeSync( fd ); +} +``` + +The function has the same default parameters as [`fs.openSync()`][node-fs]. + +
+ + + +
+ +## Notes + +- The difference between this API and [`fs.openSync()`][node-fs] is that [`fs.openSync()`][node-fs] will throw if an `error` is encountered (e.g., if given a non-existent `path`) and this API will return an `error`. Hence, the following anti-pattern + + + + ```javascript + var fs = require( 'fs' ); + + var fpath = '/path/to/file.js'; + var fd; + + // Check for existence to prevent an error being thrown... + if ( fs.existsSync( fpath ) ) { + fd = fs.readFileSync( fpath ); + } + ``` + + can be replaced by an approach which addresses existence via `error` handling. + + + + ```javascript + import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@esm/index.mjs'; + + var fpath = '/path/to/file.js'; + + // Explicitly handle the error... + var fd = open.sync( fpath ); + if ( fd instanceof Error ) { + // You choose what to do... + console.error( fd.message ); + } + ``` + +
+ + + +
+ +## 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..c6e863c --- /dev/null +++ b/index.d.ts @@ -0,0 +1,150 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2020 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 2.0 + +/// + +import { Buffer } from 'buffer'; + +/** +* Callback invoked after opening a file. +* +* @param err - error argument +* @param fd - file descriptor +*/ +type Callback = ( err: Error, fd: number ) => void; + +/** +* Interface for opening a file. +*/ +interface Open { + /** + * Asynchronously opens a file. + * + * @param path - file path + * @param flags - file system flags (default: 'r') + * @param mode - file mode (default: 0o666) + * @param clbk - callback to invoke after opening a file + * + * @example + * var closeSync = require( `@stdlib/fs/close` ).sync; + * + * function onOpen( error, fd ) { + * if ( error ) { + * throw error; + * } + * closeSync( fd ); + * } + * open( __filename, 'r+', 438, onOpen ); + */ + ( path: string | Buffer, flags: string | number, mode: number, clbk: Callback ): void; // tslint-disable-line max-line-length + + /** + * Asynchronously opens a file. + * + * @param path - file path + * @param flags - file system flags (default: 'r') + * @param clbk - callback to invoke after opening a file + * + * @example + * var closeSync = require( `@stdlib/fs/close` ).sync; + * + * function onOpen( error, fd ) { + * if ( error ) { + * throw error; + * } + * closeSync( fd ); + * } + * open( __filename, 'r+', onOpen ); + */ + ( path: string | Buffer, flags: string | number, clbk: Callback ): void; + + /** + * Asynchronously opens a file. + * + * @param path - file path + * @param clbk - callback to invoke after opening a file + * + * @example + * var closeSync = require( `@stdlib/fs/close` ).sync; + * + * function onOpen( error, fd ) { + * if ( error ) { + * throw error; + * } + * closeSync( fd ); + * } + * open( __filename, onOpen ); + */ + ( path: string | Buffer, clbk: Callback ): void; + + /** + * Synchronously opens a file. + * + * @param path - file path + * @param flags - file system flags (default: 'r') + * @param mode - file mode (default: 0o666) + * @returns file descriptor or an error + * + * @example + * var closeSync = require( `@stdlib/fs/close` ).sync; + * + * var fd = open.sync( __filename, 'r+' ); + * if ( fd instanceof Error ) { + * throw fd; + * } + * closeSync( fd ); + */ + sync( path: string | Buffer, flags?: string | number, mode?: number ): number | Error; // tslint-disable-line max-line-length +} + +/** +* Asynchronously opens a file. +* +* @param path - file path +* @param flags - file system flags (default: 'r') +* @param mode - file mode (default: 0o666) +* @param clbk - callback to invoke after opening a file +* +* @example +* var closeSync = require( `@stdlib/fs/close` ).sync; +* +* function onOpen( error, fd ) { +* if ( error ) { +* throw error; +* } +* closeSync( fd ); +* } +* open( __filename, onOpen ); +* +* @example +* var closeSync = require( `@stdlib/fs/close` ).sync; +* +* var fd = open.sync( __filename ); +* if ( fd instanceof Error ) { +* throw fd; +* } +* closeSync( fd ); +*/ +declare var open: Open; + + +// EXPORTS // + +export = open; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..f14b491 --- /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/utils-define-nonenumerable-read-only-property@esm/index.mjs";function r(e){if(e.__esModule)return e;var r=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var t=r(Object.freeze({__proto__:null,default:{}})),n={flags:"r",mode:438},o=t.open,a=n;var u=function(e,r,t,n){var u=arguments.length;return 2===u?o(e,a.flags,a.mode,r):3===u?o(e,r,a.mode,t):void o(e,r,t,n)},d=t.openSync,l=n;var c=function(e,r,t){var n,o;n=arguments.length;try{o=1===n?d(e,l.flags,l.mode):d(e,r,2===n?l.mode:t)}catch(e){return e}return o},f=u,i=c;e(f,"sync",i);var s=f;export{s as default,i as sync}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..fb27561 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var open = require( '@stdlib/fs-open' );\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nmodule.exports = open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nmodule.exports = openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var open = require( '@stdlib/fs-open' );\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var openSync = require( '@stdlib/fs-open' ).sync;\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar sync = require( './sync.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],"names":["op","require$$0","open","defaults","require$$1","main","path","flags","mode","clbk","nargs","arguments","length","openSync","sync","fd","err","require$$2","lib"],"mappings":";;qcAsBIA,EAAKC,EAAgBC,KACrBC,EAAWC,EAwCf,IAAAC,EAdA,SAAeC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGV,EAAIM,EAAMH,EAASI,MAAOJ,EAASK,KAAMD,GAElC,IAAVG,EACGV,EAAIM,EAAMC,EAAOJ,EAASK,KAAMA,QAExCR,EAAIM,EAAMC,EAAOC,EAAMC,ICnCpBP,EAAOD,EAAgBY,SACvBV,EAAWC,EA4Cf,IAAAU,EAtBA,SAAmBR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCR,EAAMI,EAAMH,EAASI,MAAOJ,EAASK,MAErCN,EAAMI,EAAMC,EADI,IAAVG,EACaP,EAASK,KAETA,GAExB,MAAQQ,GACT,OAAOA,EAER,OAAOD,GCVRV,EAAAD,EACAU,EAAAG,EAFAhB,EAOAI,EAAA,OAAAS,GAKA,IAAAI,EAAAb"} \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..2e2a6dc --- /dev/null +++ b/package.json @@ -0,0 +1,33 @@ +{ + "name": "@stdlib/fs-open", + "version": "0.0.0", + "description": "Open a file.", + "license": "Apache-2.0", + "type": "module", + "main": "./index.mjs", + "homepage": "https://stdlib.io", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/fs-open.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "keywords": [ + "stdlib", + "stdfs", + "fs", + "open", + "opensync", + "path", + "async", + "sync", + "file", + "read", + "filesystem" + ], + "funding": { + "type": "patreon", + "url": "https://www.patreon.com/athan" + } +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..99f1acb --- /dev/null +++ b/stats.html @@ -0,0 +1,2689 @@ + + + + + + + + RollUp Visualizer + + + +
+ + + + + From efb73cf2364c042f22c49bad09562ebade8cdc8f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 3 Nov 2022 23:23:24 +0000 Subject: [PATCH 002/113] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 7efe698..3d91f47 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.0.x", @@ -81,4 +82,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 3e337376efdbc0a1cdf4dfc03a4ef9df2135d5f0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 12:07:42 +0000 Subject: [PATCH 003/113] Remove files --- index.d.ts | 150 --- index.mjs | 4 - index.mjs.map | 1 - stats.html | 2689 ------------------------------------------------- 4 files changed, 2844 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 c6e863c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,150 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Buffer } from 'buffer'; - -/** -* Callback invoked after opening a file. -* -* @param err - error argument -* @param fd - file descriptor -*/ -type Callback = ( err: Error, fd: number ) => void; - -/** -* Interface for opening a file. -*/ -interface Open { - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', 438, onOpen ); - */ - ( path: string | Buffer, flags: string | number, mode: number, clbk: Callback ): void; // tslint-disable-line max-line-length - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', onOpen ); - */ - ( path: string | Buffer, flags: string | number, clbk: Callback ): void; - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, onOpen ); - */ - ( path: string | Buffer, clbk: Callback ): void; - - /** - * Synchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @returns file descriptor or an error - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * var fd = open.sync( __filename, 'r+' ); - * if ( fd instanceof Error ) { - * throw fd; - * } - * closeSync( fd ); - */ - sync( path: string | Buffer, flags?: string | number, mode?: number ): number | Error; // tslint-disable-line max-line-length -} - -/** -* Asynchronously opens a file. -* -* @param path - file path -* @param flags - file system flags (default: 'r') -* @param mode - file mode (default: 0o666) -* @param clbk - callback to invoke after opening a file -* -* @example -* var closeSync = require( `@stdlib/fs/close` ).sync; -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( `@stdlib/fs/close` ).sync; -* -* var fd = open.sync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -declare var open: Open; - - -// EXPORTS // - -export = open; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index f14b491..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/utils-define-nonenumerable-read-only-property@esm/index.mjs";function r(e){if(e.__esModule)return e;var r=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var t=r(Object.freeze({__proto__:null,default:{}})),n={flags:"r",mode:438},o=t.open,a=n;var u=function(e,r,t,n){var u=arguments.length;return 2===u?o(e,a.flags,a.mode,r):3===u?o(e,r,a.mode,t):void o(e,r,t,n)},d=t.openSync,l=n;var c=function(e,r,t){var n,o;n=arguments.length;try{o=1===n?d(e,l.flags,l.mode):d(e,r,2===n?l.mode:t)}catch(e){return e}return o},f=u,i=c;e(f,"sync",i);var s=f;export{s as default,i as sync}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index fb27561..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var open = require( '@stdlib/fs-open' );\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nmodule.exports = open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nmodule.exports = openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var open = require( '@stdlib/fs-open' );\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var openSync = require( '@stdlib/fs-open' ).sync;\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar sync = require( './sync.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],"names":["op","require$$0","open","defaults","require$$1","main","path","flags","mode","clbk","nargs","arguments","length","openSync","sync","fd","err","require$$2","lib"],"mappings":";;qcAsBIA,EAAKC,EAAgBC,KACrBC,EAAWC,EAwCf,IAAAC,EAdA,SAAeC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGV,EAAIM,EAAMH,EAASI,MAAOJ,EAASK,KAAMD,GAElC,IAAVG,EACGV,EAAIM,EAAMC,EAAOJ,EAASK,KAAMA,QAExCR,EAAIM,EAAMC,EAAOC,EAAMC,ICnCpBP,EAAOD,EAAgBY,SACvBV,EAAWC,EA4Cf,IAAAU,EAtBA,SAAmBR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCR,EAAMI,EAAMH,EAASI,MAAOJ,EAASK,MAErCN,EAAMI,EAAMC,EADI,IAAVG,EACaP,EAASK,KAETA,GAExB,MAAQQ,GACT,OAAOA,EAER,OAAOD,GCVRV,EAAAD,EACAU,EAAAG,EAFAhB,EAOAI,EAAA,OAAAS,GAKA,IAAAI,EAAAb"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 99f1acb..0000000 --- a/stats.html +++ /dev/null @@ -1,2689 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From e9c06d93fc4fd664fe75f7cf358c9f87248ef2a2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 4 Nov 2022 12:08:18 +0000 Subject: [PATCH 004/113] 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 | 53 +- benchmark/benchmark.js | 77 - branches.md | 53 - docs/repl.txt | 65 - docs/types/test.ts | 129 - examples/index.js | 56 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/defaults.json | 4 - lib/index.js | 63 - lib/main.js | 64 - lib/sync.js | 68 - package.json | 58 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 38 - test/test.main.js | 110 - test/test.sync.js | 83 - 41 files changed, 4078 insertions(+), 3817 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/defaults.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/sync.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.sync.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 9db3680..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-11-03T20:48:32.149Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index a3a4470..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/fs/open) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 5eb1ff1..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/fs/open) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 3201e5c..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: '14 2 * * 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 + + ```
@@ -212,7 +211,7 @@ function onOpen( error, fd ) { ## 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]. @@ -276,11 +275,11 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close +[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close/tree/esm -[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists +[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists/tree/esm -[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file +[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 567aec3..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,77 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var closeSync = require( '@stdlib/fs-close' ).sync; -var pkg = require( './../package.json' ).name; -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return open( __filename, 'r+', done ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function done( error, fd ) { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - if ( error ) { - b.fail( error.message ); - } - next(); - } -}); - -bench( pkg+':sync', function benchmark( b ) { - var fd; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - fd = open.sync( __filename, 'r+' ); - if ( fd instanceof Error ) { - b.fail( fd.message ); - } else { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - } - } - b.toc(); - if ( fd instanceof Error ) { - b.fail( 'something went wrong' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 8f17b03..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/fs/open" -click B href "https://github.com/stdlib-js/fs-open/tree/main" -click C href "https://github.com/stdlib-js/fs-open/tree/production" -click D href "https://github.com/stdlib-js/fs-open/tree/esm" -click E href "https://github.com/stdlib-js/fs-open/tree/deno" -click F href "https://github.com/stdlib-js/fs-open/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/fs/open -[production-url]: https://github.com/stdlib-js/fs-open/tree/production -[deno-url]: https://github.com/stdlib-js/fs-open/tree/deno -[umd-url]: https://github.com/stdlib-js/fs-open/tree/umd -[esm-url]: https://github.com/stdlib-js/fs-open/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4cbf7ac..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,65 +0,0 @@ - -{{alias}}( path[, flags[, mode]], clbk ) - Asynchronously opens a file. - - Some characters, such as <>:"/\|?*, are reserved under Windows. - Under NTFS, if the path contains a colon, Node.js will open a file system - stream. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - clbk: Function - Callback to invoke upon opening a file. - - Examples - -------- - > function onOpen( error, fd ) { - ... if ( error ) { - ... console.error( error.message ); - ... } else { - ... {{alias:@stdlib/fs/close}}.sync( fd ); - ... } - ... }; - > {{alias}}( './beep/boop.txt', onOpen ); - - -{{alias}}.sync( path[, flags[, mode]] ) - Synchronously opens a file. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - Returns - ------- - fd: Error|integer - File descriptor. - - Examples - -------- - > var fd = {{alias}}.sync( './beep/boop.txt' ); - > if ( !{{alias:@stdlib/assert/is-error}}( fd ) ) { {{alias:@stdlib/fs/close}}.sync( fd ); }; - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 67907a2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,129 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 open = require( './index' ); - -const done = ( error: Error, fd: number ) => { - if ( error || !fd ) { - throw error; - } -}; - - -// TESTS // - -// The function does not have a return value... -{ - open( '/path/to/beepboop', done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a string... -{ - open( 123, done ); // $ExpectError - open( false, done ); // $ExpectError - open( true, done ); // $ExpectError - open( null, done ); // $ExpectError - open( undefined, done ); // $ExpectError - open( [], done ); // $ExpectError - open( {}, done ); // $ExpectError - open( ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a last argument which is not a function with the expected signature... -{ - open( '/path/to/beepboop', 'abc' ); // $ExpectError - open( '/path/to/beepboop', 123 ); // $ExpectError - open( '/path/to/beepboop', false ); // $ExpectError - open( '/path/to/beepboop', true ); // $ExpectError - open( '/path/to/beepboop', null ); // $ExpectError - open( '/path/to/beepboop', undefined ); // $ExpectError - open( '/path/to/beepboop', [] ); // $ExpectError - open( '/path/to/beepboop', {} ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `flags` argument which is not a string or number... -{ - open( '/path/to/beepboop', false, done ); // $ExpectError - open( '/path/to/beepboop', true, done ); // $ExpectError - open( '/path/to/beepboop', null, done ); // $ExpectError - open( '/path/to/beepboop', undefined, done ); // $ExpectError - open( '/path/to/beepboop', [], done ); // $ExpectError - open( '/path/to/beepboop', {}, done ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` argument which is not a number... -{ - open( '/path/to/beepboop', 'r+', 'abc', done ); // $ExpectError - open( '/path/to/beepboop', 'r+', false, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', true, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', null, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', undefined, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', [], done ); // $ExpectError - open( '/path/to/beepboop', 'r+', {}, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - open(); // $ExpectError - open( 'C:\\foo\\bar\\baz' ); // $ExpectError -} - -// Attached to main export is a `sync` method which returns a number or an error... -{ - open.sync( '/path/to/beepboop' ); // $ExpectType number | Error -} - -// The compiler throws an error if the `sync` method is provided a first argument which is not a string... -{ - open.sync( 123 ); // $ExpectError - open.sync( false ); // $ExpectError - open.sync( true ); // $ExpectError - open.sync( null ); // $ExpectError - open.sync( undefined ); // $ExpectError - open.sync( [] ); // $ExpectError - open.sync( {} ); // $ExpectError - open.sync( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a second argument which is not a string or number... -{ - open.sync( '/path/to/beepboop', false ); // $ExpectError - open.sync( '/path/to/beepboop', true ); // $ExpectError - open.sync( '/path/to/beepboop', null ); // $ExpectError - open.sync( '/path/to/beepboop', [] ); // $ExpectError - open.sync( '/path/to/beepboop', {} ); // $ExpectError - open.sync( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a third argument which is not a number... -{ - open.sync( '/path/to/beepboop', 'r+', false ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', true ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', null ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', [] ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', {} ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided an unsupported number of arguments... -{ - open.sync(); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 71359fe..0000000 --- a/examples/index.js +++ /dev/null @@ -1,56 +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. -*/ - -'use strict'; - -var closeSync = require( '@stdlib/fs-close' ).sync; -var isError = require( '@stdlib/assert-is-error' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - -/* Sync */ - -var fd = open.sync( __filename, 'r+' ); -// returns - -console.log( isError( fd ) ); -// => false - -closeSync( fd ); - -fd = open.sync( 'beepboop' ); -// returns - -console.log( isError( fd ) ); -// => true - -/* Async */ - -open( __filename, onOpen ); -open( 'beepboop', onOpen ); - -function onOpen( error, fd ) { - if ( error ) { - if ( error.code === 'ENOENT' ) { - console.error( 'File does not exist.' ); - } else { - throw error; - } - } else { - closeSync( fd ); - } -} 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..2b6b0f5 --- /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/utils-define-nonenumerable-read-only-property@esm/index.mjs";function t(e){var t=e.default;if("function"==typeof t){var r=function(){return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var r=t(Object.freeze({__proto__:null,default:{}})),n="r",o=438,u=r.open;function c(e,t,r,c){var a=arguments.length;return 2===a?u(e,n,o,t):3===a?u(e,t,o,r):void u(e,t,r,c)}var a=r.openSync;function i(e,t,r){var u,c;u=arguments.length;try{c=1===u?a(e,n,o):a(e,t,2===u?o:r)}catch(e){return e}return c}e(c,"sync",i);export{c as default,i as sync}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..5a2455b --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json' ;\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close' ;\n* import open from '@stdlib/fs-open' ;\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json' ;\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close' ;\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close' ;\n* import open from '@stdlib/fs-open' ;\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close' ;\n* import { sync as openSync } from '@stdlib/fs-open' ;\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport main from './main.js' ;\nimport sync from './sync.js' ;\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;shBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAIzB,CAFC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index cb174b7..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "flags": "r", - "mode": 438 -} diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 8edd6de..0000000 --- a/lib/index.js +++ /dev/null @@ -1,63 +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. -*/ - -'use strict'; - -/** -* Open a file. -* -* @module @stdlib/fs-open -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var openSync = require( '@stdlib/fs-open' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var sync = require( './sync.js' ); - - -// MAIN // - -setReadOnly( main, 'sync', sync ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index feb5171..0000000 --- a/lib/main.js +++ /dev/null @@ -1,64 +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. -*/ - -'use strict'; - -// MODULES // - -var op = require( 'fs' ).open; -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Asynchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @param {Function} clbk - callback to invoke after opening a file -* @returns {void} -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -*/ -function open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare - var nargs = arguments.length; - if ( nargs === 2 ) { - return op( path, defaults.flags, defaults.mode, flags ); - } - if ( nargs === 3 ) { - return op( path, flags, defaults.mode, mode ); - } - op( path, flags, mode, clbk ); -} - - -// EXPORTS // - -module.exports = open; diff --git a/lib/sync.js b/lib/sync.js deleted file mode 100644 index d8d2e00..0000000 --- a/lib/sync.js +++ /dev/null @@ -1,68 +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. -*/ - -'use strict'; - -// MODULES // - -var open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Synchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @returns {(integer|Error)} file descriptor or an error -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -function openSync( path, flags, mode ) { - var nargs; - var fd; - - nargs = arguments.length; - try { - if ( nargs === 1 ) { - fd = open( path, defaults.flags, defaults.mode ); - } else if ( nargs === 2 ) { - fd = open( path, flags, defaults.mode ); - } else { - fd = open( path, flags, mode ); - } - } catch ( err ) { - return err; - } - return fd; -} - - -// EXPORTS // - -module.exports = openSync; diff --git a/package.json b/package.json index 3d91f47..35358b5 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Open a file.", "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/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.0.x", - "@stdlib/assert-is-error": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/fs-close": "^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", "stdfs", @@ -82,4 +30,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..8e11941 --- /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 7d5a851..0000000 --- a/test/test.js +++ /dev/null @@ -1,38 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is a function to open a file synchronously', function test( t ) { - t.equal( typeof open.sync, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index b58a6e1..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,110 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/main.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - open( __filename, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - open( __filename, 'r+', onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - open( __filename, 'r+', 438, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - open( 'beepboopbapbop', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', 438, onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); diff --git a/test/test.sync.js b/test/test.sync.js deleted file mode 100644 index 5132589..0000000 --- a/test/test.sync.js +++ /dev/null @@ -1,83 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/sync.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - var fd = open( __filename ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - var fd = open( __filename, 'r+' ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - var fd = open( __filename, 'r+', 438 ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - var fd = open( 'beepboopbapbop' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+', 438 ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); From 63f7d41361d9eab510bc6aee5b5fbf34b0a1b6db Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 03:06:28 +0000 Subject: [PATCH 005/113] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 8887d69..7d224d4 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.0.x", @@ -81,4 +82,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From 2040e8b60536b4239065dfa8f29d76aa8bf027a8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 13:06:41 +0000 Subject: [PATCH 006/113] Remove files --- index.d.ts | 150 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4199 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 c6e863c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,150 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Buffer } from 'buffer'; - -/** -* Callback invoked after opening a file. -* -* @param err - error argument -* @param fd - file descriptor -*/ -type Callback = ( err: Error, fd: number ) => void; - -/** -* Interface for opening a file. -*/ -interface Open { - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', 438, onOpen ); - */ - ( path: string | Buffer, flags: string | number, mode: number, clbk: Callback ): void; // tslint-disable-line max-line-length - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', onOpen ); - */ - ( path: string | Buffer, flags: string | number, clbk: Callback ): void; - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, onOpen ); - */ - ( path: string | Buffer, clbk: Callback ): void; - - /** - * Synchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @returns file descriptor or an error - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * var fd = open.sync( __filename, 'r+' ); - * if ( fd instanceof Error ) { - * throw fd; - * } - * closeSync( fd ); - */ - sync( path: string | Buffer, flags?: string | number, mode?: number ): number | Error; // tslint-disable-line max-line-length -} - -/** -* Asynchronously opens a file. -* -* @param path - file path -* @param flags - file system flags (default: 'r') -* @param mode - file mode (default: 0o666) -* @param clbk - callback to invoke after opening a file -* -* @example -* var closeSync = require( `@stdlib/fs/close` ).sync; -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( `@stdlib/fs/close` ).sync; -* -* var fd = open.sync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -declare var open: Open; - - -// EXPORTS // - -export = open; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 2b6b0f5..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/utils-define-nonenumerable-read-only-property@esm/index.mjs";function t(e){var t=e.default;if("function"==typeof t){var r=function(){return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var r=t(Object.freeze({__proto__:null,default:{}})),n="r",o=438,u=r.open;function c(e,t,r,c){var a=arguments.length;return 2===a?u(e,n,o,t):3===a?u(e,t,o,r):void u(e,t,r,c)}var a=r.openSync;function i(e,t,r){var u,c;u=arguments.length;try{c=1===u?a(e,n,o):a(e,t,2===u?o:r)}catch(e){return e}return c}e(c,"sync",i);export{c as default,i as sync}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 5a2455b..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json' ;\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close' ;\n* import open from '@stdlib/fs-open' ;\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json' ;\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close' ;\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close' ;\n* import open from '@stdlib/fs-open' ;\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close' ;\n* import { sync as openSync } from '@stdlib/fs-open' ;\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property' ;\nimport main from './main.js' ;\nimport sync from './sync.js' ;\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;shBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAIzB,CAFC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 8e11941..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From f72273d16161e072f9bc08131ec6e259ccf25c86 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Dec 2022 13:07:20 +0000 Subject: [PATCH 007/113] 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 | 53 +- benchmark/benchmark.js | 77 - branches.md | 53 - docs/repl.txt | 65 - docs/types/test.ts | 129 - examples/index.js | 56 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/defaults.json | 4 - lib/index.js | 63 - lib/main.js | 64 - lib/sync.js | 68 - package.json | 58 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 38 - test/test.main.js | 110 - test/test.sync.js | 83 - 41 files changed, 4078 insertions(+), 3822 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/defaults.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/sync.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.sync.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 2bae812..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2022-12-01T00:40:11.425Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index a3a4470..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/fs/open) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 5eb1ff1..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/fs/open) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 3201e5c..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: '14 2 * * 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 + + ```
@@ -212,7 +211,7 @@ function onOpen( error, fd ) { ## 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]. @@ -276,11 +275,11 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors]. -[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close +[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close/tree/esm -[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists +[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists/tree/esm -[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file +[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 567aec3..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,77 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var closeSync = require( '@stdlib/fs-close' ).sync; -var pkg = require( './../package.json' ).name; -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return open( __filename, 'r+', done ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function done( error, fd ) { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - if ( error ) { - b.fail( error.message ); - } - next(); - } -}); - -bench( pkg+':sync', function benchmark( b ) { - var fd; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - fd = open.sync( __filename, 'r+' ); - if ( fd instanceof Error ) { - b.fail( fd.message ); - } else { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - } - } - b.toc(); - if ( fd instanceof Error ) { - b.fail( 'something went wrong' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 8f17b03..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/fs/open" -click B href "https://github.com/stdlib-js/fs-open/tree/main" -click C href "https://github.com/stdlib-js/fs-open/tree/production" -click D href "https://github.com/stdlib-js/fs-open/tree/esm" -click E href "https://github.com/stdlib-js/fs-open/tree/deno" -click F href "https://github.com/stdlib-js/fs-open/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/fs/open -[production-url]: https://github.com/stdlib-js/fs-open/tree/production -[deno-url]: https://github.com/stdlib-js/fs-open/tree/deno -[umd-url]: https://github.com/stdlib-js/fs-open/tree/umd -[esm-url]: https://github.com/stdlib-js/fs-open/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4cbf7ac..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,65 +0,0 @@ - -{{alias}}( path[, flags[, mode]], clbk ) - Asynchronously opens a file. - - Some characters, such as <>:"/\|?*, are reserved under Windows. - Under NTFS, if the path contains a colon, Node.js will open a file system - stream. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - clbk: Function - Callback to invoke upon opening a file. - - Examples - -------- - > function onOpen( error, fd ) { - ... if ( error ) { - ... console.error( error.message ); - ... } else { - ... {{alias:@stdlib/fs/close}}.sync( fd ); - ... } - ... }; - > {{alias}}( './beep/boop.txt', onOpen ); - - -{{alias}}.sync( path[, flags[, mode]] ) - Synchronously opens a file. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - Returns - ------- - fd: Error|integer - File descriptor. - - Examples - -------- - > var fd = {{alias}}.sync( './beep/boop.txt' ); - > if ( !{{alias:@stdlib/assert/is-error}}( fd ) ) { {{alias:@stdlib/fs/close}}.sync( fd ); }; - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 67907a2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,129 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 open = require( './index' ); - -const done = ( error: Error, fd: number ) => { - if ( error || !fd ) { - throw error; - } -}; - - -// TESTS // - -// The function does not have a return value... -{ - open( '/path/to/beepboop', done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a string... -{ - open( 123, done ); // $ExpectError - open( false, done ); // $ExpectError - open( true, done ); // $ExpectError - open( null, done ); // $ExpectError - open( undefined, done ); // $ExpectError - open( [], done ); // $ExpectError - open( {}, done ); // $ExpectError - open( ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a last argument which is not a function with the expected signature... -{ - open( '/path/to/beepboop', 'abc' ); // $ExpectError - open( '/path/to/beepboop', 123 ); // $ExpectError - open( '/path/to/beepboop', false ); // $ExpectError - open( '/path/to/beepboop', true ); // $ExpectError - open( '/path/to/beepboop', null ); // $ExpectError - open( '/path/to/beepboop', undefined ); // $ExpectError - open( '/path/to/beepboop', [] ); // $ExpectError - open( '/path/to/beepboop', {} ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `flags` argument which is not a string or number... -{ - open( '/path/to/beepboop', false, done ); // $ExpectError - open( '/path/to/beepboop', true, done ); // $ExpectError - open( '/path/to/beepboop', null, done ); // $ExpectError - open( '/path/to/beepboop', undefined, done ); // $ExpectError - open( '/path/to/beepboop', [], done ); // $ExpectError - open( '/path/to/beepboop', {}, done ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` argument which is not a number... -{ - open( '/path/to/beepboop', 'r+', 'abc', done ); // $ExpectError - open( '/path/to/beepboop', 'r+', false, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', true, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', null, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', undefined, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', [], done ); // $ExpectError - open( '/path/to/beepboop', 'r+', {}, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - open(); // $ExpectError - open( 'C:\\foo\\bar\\baz' ); // $ExpectError -} - -// Attached to main export is a `sync` method which returns a number or an error... -{ - open.sync( '/path/to/beepboop' ); // $ExpectType number | Error -} - -// The compiler throws an error if the `sync` method is provided a first argument which is not a string... -{ - open.sync( 123 ); // $ExpectError - open.sync( false ); // $ExpectError - open.sync( true ); // $ExpectError - open.sync( null ); // $ExpectError - open.sync( undefined ); // $ExpectError - open.sync( [] ); // $ExpectError - open.sync( {} ); // $ExpectError - open.sync( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a second argument which is not a string or number... -{ - open.sync( '/path/to/beepboop', false ); // $ExpectError - open.sync( '/path/to/beepboop', true ); // $ExpectError - open.sync( '/path/to/beepboop', null ); // $ExpectError - open.sync( '/path/to/beepboop', [] ); // $ExpectError - open.sync( '/path/to/beepboop', {} ); // $ExpectError - open.sync( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a third argument which is not a number... -{ - open.sync( '/path/to/beepboop', 'r+', false ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', true ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', null ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', [] ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', {} ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided an unsupported number of arguments... -{ - open.sync(); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 71359fe..0000000 --- a/examples/index.js +++ /dev/null @@ -1,56 +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. -*/ - -'use strict'; - -var closeSync = require( '@stdlib/fs-close' ).sync; -var isError = require( '@stdlib/assert-is-error' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - -/* Sync */ - -var fd = open.sync( __filename, 'r+' ); -// returns - -console.log( isError( fd ) ); -// => false - -closeSync( fd ); - -fd = open.sync( 'beepboop' ); -// returns - -console.log( isError( fd ) ); -// => true - -/* Async */ - -open( __filename, onOpen ); -open( 'beepboop', onOpen ); - -function onOpen( error, fd ) { - if ( error ) { - if ( error.code === 'ENOENT' ) { - console.error( 'File does not exist.' ); - } else { - throw error; - } - } else { - closeSync( fd ); - } -} 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..2b6b0f5 --- /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/utils-define-nonenumerable-read-only-property@esm/index.mjs";function t(e){var t=e.default;if("function"==typeof t){var r=function(){return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var r=t(Object.freeze({__proto__:null,default:{}})),n="r",o=438,u=r.open;function c(e,t,r,c){var a=arguments.length;return 2===a?u(e,n,o,t):3===a?u(e,t,o,r):void u(e,t,r,c)}var a=r.openSync;function i(e,t,r){var u,c;u=arguments.length;try{c=1===u?a(e,n,o):a(e,t,2===u?o:r)}catch(e){return e}return c}e(c,"sync",i);export{c as default,i as sync}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7e37074 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;shBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAIzB,CAFC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index cb174b7..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "flags": "r", - "mode": 438 -} diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 8edd6de..0000000 --- a/lib/index.js +++ /dev/null @@ -1,63 +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. -*/ - -'use strict'; - -/** -* Open a file. -* -* @module @stdlib/fs-open -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var openSync = require( '@stdlib/fs-open' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var sync = require( './sync.js' ); - - -// MAIN // - -setReadOnly( main, 'sync', sync ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index feb5171..0000000 --- a/lib/main.js +++ /dev/null @@ -1,64 +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. -*/ - -'use strict'; - -// MODULES // - -var op = require( 'fs' ).open; -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Asynchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @param {Function} clbk - callback to invoke after opening a file -* @returns {void} -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -*/ -function open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare - var nargs = arguments.length; - if ( nargs === 2 ) { - return op( path, defaults.flags, defaults.mode, flags ); - } - if ( nargs === 3 ) { - return op( path, flags, defaults.mode, mode ); - } - op( path, flags, mode, clbk ); -} - - -// EXPORTS // - -module.exports = open; diff --git a/lib/sync.js b/lib/sync.js deleted file mode 100644 index d8d2e00..0000000 --- a/lib/sync.js +++ /dev/null @@ -1,68 +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. -*/ - -'use strict'; - -// MODULES // - -var open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Synchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @returns {(integer|Error)} file descriptor or an error -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -function openSync( path, flags, mode ) { - var nargs; - var fd; - - nargs = arguments.length; - try { - if ( nargs === 1 ) { - fd = open( path, defaults.flags, defaults.mode ); - } else if ( nargs === 2 ) { - fd = open( path, flags, defaults.mode ); - } else { - fd = open( path, flags, mode ); - } - } catch ( err ) { - return err; - } - return fd; -} - - -// EXPORTS // - -module.exports = openSync; diff --git a/package.json b/package.json index 7d224d4..35358b5 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Open a file.", "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/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.0.x", - "@stdlib/assert-is-error": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/fs-close": "^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", "stdfs", @@ -82,4 +30,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..337d947 --- /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 7d5a851..0000000 --- a/test/test.js +++ /dev/null @@ -1,38 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is a function to open a file synchronously', function test( t ) { - t.equal( typeof open.sync, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index b58a6e1..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,110 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/main.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - open( __filename, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - open( __filename, 'r+', onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - open( __filename, 'r+', 438, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - open( 'beepboopbapbop', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', 438, onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); diff --git a/test/test.sync.js b/test/test.sync.js deleted file mode 100644 index 5132589..0000000 --- a/test/test.sync.js +++ /dev/null @@ -1,83 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/sync.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - var fd = open( __filename ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - var fd = open( __filename, 'r+' ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - var fd = open( __filename, 'r+', 438 ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - var fd = open( 'beepboopbapbop' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+', 438 ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); From 7006ea9623111b8061d6946ccb7534e5aa6fe787 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Jan 2023 02:30:52 +0000 Subject: [PATCH 008/113] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 4cb01c7..2e09ca2 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.0.x", @@ -81,4 +82,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From b6b701def7453fbc8132ff5390ac209001c21343 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Jan 2023 06:39:03 +0000 Subject: [PATCH 009/113] Remove files --- index.d.ts | 150 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4199 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 c6e863c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,150 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Buffer } from 'buffer'; - -/** -* Callback invoked after opening a file. -* -* @param err - error argument -* @param fd - file descriptor -*/ -type Callback = ( err: Error, fd: number ) => void; - -/** -* Interface for opening a file. -*/ -interface Open { - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', 438, onOpen ); - */ - ( path: string | Buffer, flags: string | number, mode: number, clbk: Callback ): void; // tslint-disable-line max-line-length - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', onOpen ); - */ - ( path: string | Buffer, flags: string | number, clbk: Callback ): void; - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, onOpen ); - */ - ( path: string | Buffer, clbk: Callback ): void; - - /** - * Synchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @returns file descriptor or an error - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * var fd = open.sync( __filename, 'r+' ); - * if ( fd instanceof Error ) { - * throw fd; - * } - * closeSync( fd ); - */ - sync( path: string | Buffer, flags?: string | number, mode?: number ): number | Error; // tslint-disable-line max-line-length -} - -/** -* Asynchronously opens a file. -* -* @param path - file path -* @param flags - file system flags (default: 'r') -* @param mode - file mode (default: 0o666) -* @param clbk - callback to invoke after opening a file -* -* @example -* var closeSync = require( `@stdlib/fs/close` ).sync; -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( `@stdlib/fs/close` ).sync; -* -* var fd = open.sync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -declare var open: Open; - - -// EXPORTS // - -export = open; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 2b6b0f5..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/utils-define-nonenumerable-read-only-property@esm/index.mjs";function t(e){var t=e.default;if("function"==typeof t){var r=function(){return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var r=t(Object.freeze({__proto__:null,default:{}})),n="r",o=438,u=r.open;function c(e,t,r,c){var a=arguments.length;return 2===a?u(e,n,o,t):3===a?u(e,t,o,r):void u(e,t,r,c)}var a=r.openSync;function i(e,t,r){var u,c;u=arguments.length;try{c=1===u?a(e,n,o):a(e,t,2===u?o:r)}catch(e){return e}return c}e(c,"sync",i);export{c as default,i as sync}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7e37074..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;shBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAIzB,CAFC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 337d947..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 462a1e2ed51eafdb290098389249cfca33e5d3ab Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Jan 2023 06:39:48 +0000 Subject: [PATCH 010/113] 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 | 53 +- benchmark/benchmark.js | 77 - branches.md | 53 - docs/repl.txt | 65 - docs/types/test.ts | 129 - examples/index.js | 56 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/defaults.json | 4 - lib/index.js | 63 - lib/main.js | 64 - lib/sync.js | 68 - package.json | 58 +- stats.html | 4044 +++++++++++++++++++++ test/test.js | 38 - test/test.main.js | 110 - test/test.sync.js | 83 - 41 files changed, 4078 insertions(+), 3833 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/defaults.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/sync.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.sync.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 66dcacf..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-01-01T00:35:13.359Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index a3a4470..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/fs/open) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 5eb1ff1..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/fs/open) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 3201e5c..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: '14 2 * * 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 + + ```
@@ -212,7 +211,7 @@ function onOpen( error, fd ) { ## 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]. @@ -276,11 +275,11 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close +[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close/tree/esm -[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists +[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists/tree/esm -[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file +[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 567aec3..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,77 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var closeSync = require( '@stdlib/fs-close' ).sync; -var pkg = require( './../package.json' ).name; -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return open( __filename, 'r+', done ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function done( error, fd ) { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - if ( error ) { - b.fail( error.message ); - } - next(); - } -}); - -bench( pkg+':sync', function benchmark( b ) { - var fd; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - fd = open.sync( __filename, 'r+' ); - if ( fd instanceof Error ) { - b.fail( fd.message ); - } else { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - } - } - b.toc(); - if ( fd instanceof Error ) { - b.fail( 'something went wrong' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 8f17b03..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/fs/open" -click B href "https://github.com/stdlib-js/fs-open/tree/main" -click C href "https://github.com/stdlib-js/fs-open/tree/production" -click D href "https://github.com/stdlib-js/fs-open/tree/esm" -click E href "https://github.com/stdlib-js/fs-open/tree/deno" -click F href "https://github.com/stdlib-js/fs-open/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/fs/open -[production-url]: https://github.com/stdlib-js/fs-open/tree/production -[deno-url]: https://github.com/stdlib-js/fs-open/tree/deno -[umd-url]: https://github.com/stdlib-js/fs-open/tree/umd -[esm-url]: https://github.com/stdlib-js/fs-open/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4cbf7ac..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,65 +0,0 @@ - -{{alias}}( path[, flags[, mode]], clbk ) - Asynchronously opens a file. - - Some characters, such as <>:"/\|?*, are reserved under Windows. - Under NTFS, if the path contains a colon, Node.js will open a file system - stream. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - clbk: Function - Callback to invoke upon opening a file. - - Examples - -------- - > function onOpen( error, fd ) { - ... if ( error ) { - ... console.error( error.message ); - ... } else { - ... {{alias:@stdlib/fs/close}}.sync( fd ); - ... } - ... }; - > {{alias}}( './beep/boop.txt', onOpen ); - - -{{alias}}.sync( path[, flags[, mode]] ) - Synchronously opens a file. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - Returns - ------- - fd: Error|integer - File descriptor. - - Examples - -------- - > var fd = {{alias}}.sync( './beep/boop.txt' ); - > if ( !{{alias:@stdlib/assert/is-error}}( fd ) ) { {{alias:@stdlib/fs/close}}.sync( fd ); }; - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 67907a2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,129 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 open = require( './index' ); - -const done = ( error: Error, fd: number ) => { - if ( error || !fd ) { - throw error; - } -}; - - -// TESTS // - -// The function does not have a return value... -{ - open( '/path/to/beepboop', done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a string... -{ - open( 123, done ); // $ExpectError - open( false, done ); // $ExpectError - open( true, done ); // $ExpectError - open( null, done ); // $ExpectError - open( undefined, done ); // $ExpectError - open( [], done ); // $ExpectError - open( {}, done ); // $ExpectError - open( ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a last argument which is not a function with the expected signature... -{ - open( '/path/to/beepboop', 'abc' ); // $ExpectError - open( '/path/to/beepboop', 123 ); // $ExpectError - open( '/path/to/beepboop', false ); // $ExpectError - open( '/path/to/beepboop', true ); // $ExpectError - open( '/path/to/beepboop', null ); // $ExpectError - open( '/path/to/beepboop', undefined ); // $ExpectError - open( '/path/to/beepboop', [] ); // $ExpectError - open( '/path/to/beepboop', {} ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `flags` argument which is not a string or number... -{ - open( '/path/to/beepboop', false, done ); // $ExpectError - open( '/path/to/beepboop', true, done ); // $ExpectError - open( '/path/to/beepboop', null, done ); // $ExpectError - open( '/path/to/beepboop', undefined, done ); // $ExpectError - open( '/path/to/beepboop', [], done ); // $ExpectError - open( '/path/to/beepboop', {}, done ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` argument which is not a number... -{ - open( '/path/to/beepboop', 'r+', 'abc', done ); // $ExpectError - open( '/path/to/beepboop', 'r+', false, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', true, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', null, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', undefined, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', [], done ); // $ExpectError - open( '/path/to/beepboop', 'r+', {}, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - open(); // $ExpectError - open( 'C:\\foo\\bar\\baz' ); // $ExpectError -} - -// Attached to main export is a `sync` method which returns a number or an error... -{ - open.sync( '/path/to/beepboop' ); // $ExpectType number | Error -} - -// The compiler throws an error if the `sync` method is provided a first argument which is not a string... -{ - open.sync( 123 ); // $ExpectError - open.sync( false ); // $ExpectError - open.sync( true ); // $ExpectError - open.sync( null ); // $ExpectError - open.sync( undefined ); // $ExpectError - open.sync( [] ); // $ExpectError - open.sync( {} ); // $ExpectError - open.sync( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a second argument which is not a string or number... -{ - open.sync( '/path/to/beepboop', false ); // $ExpectError - open.sync( '/path/to/beepboop', true ); // $ExpectError - open.sync( '/path/to/beepboop', null ); // $ExpectError - open.sync( '/path/to/beepboop', [] ); // $ExpectError - open.sync( '/path/to/beepboop', {} ); // $ExpectError - open.sync( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a third argument which is not a number... -{ - open.sync( '/path/to/beepboop', 'r+', false ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', true ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', null ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', [] ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', {} ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided an unsupported number of arguments... -{ - open.sync(); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 71359fe..0000000 --- a/examples/index.js +++ /dev/null @@ -1,56 +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. -*/ - -'use strict'; - -var closeSync = require( '@stdlib/fs-close' ).sync; -var isError = require( '@stdlib/assert-is-error' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - -/* Sync */ - -var fd = open.sync( __filename, 'r+' ); -// returns - -console.log( isError( fd ) ); -// => false - -closeSync( fd ); - -fd = open.sync( 'beepboop' ); -// returns - -console.log( isError( fd ) ); -// => true - -/* Async */ - -open( __filename, onOpen ); -open( 'beepboop', onOpen ); - -function onOpen( error, fd ) { - if ( error ) { - if ( error.code === 'ENOENT' ) { - console.error( 'File does not exist.' ); - } else { - throw error; - } - } else { - closeSync( fd ); - } -} 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..3b5cb44 --- /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/utils-define-nonenumerable-read-only-property@esm/index.mjs";function t(e){var t=e.default;if("function"==typeof t){var r=function(){return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var r=t(Object.freeze({__proto__:null,default:{}})),n="r",o=438,u=r.open;function c(e,t,r,c){var a=arguments.length;return 2===a?u(e,n,o,t):3===a?u(e,t,o,r):void u(e,t,r,c)}var a=r.openSync;function i(e,t,r){var u,c;u=arguments.length;try{c=1===u?a(e,n,o):a(e,t,2===u?o:r)}catch(e){return e}return c}e(c,"sync",i);export{c as default,i as sync}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..7e37074 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;shBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAIzB,CAFC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index cb174b7..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "flags": "r", - "mode": 438 -} diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 8edd6de..0000000 --- a/lib/index.js +++ /dev/null @@ -1,63 +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. -*/ - -'use strict'; - -/** -* Open a file. -* -* @module @stdlib/fs-open -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var openSync = require( '@stdlib/fs-open' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var sync = require( './sync.js' ); - - -// MAIN // - -setReadOnly( main, 'sync', sync ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index feb5171..0000000 --- a/lib/main.js +++ /dev/null @@ -1,64 +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. -*/ - -'use strict'; - -// MODULES // - -var op = require( 'fs' ).open; -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Asynchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @param {Function} clbk - callback to invoke after opening a file -* @returns {void} -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -*/ -function open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare - var nargs = arguments.length; - if ( nargs === 2 ) { - return op( path, defaults.flags, defaults.mode, flags ); - } - if ( nargs === 3 ) { - return op( path, flags, defaults.mode, mode ); - } - op( path, flags, mode, clbk ); -} - - -// EXPORTS // - -module.exports = open; diff --git a/lib/sync.js b/lib/sync.js deleted file mode 100644 index d8d2e00..0000000 --- a/lib/sync.js +++ /dev/null @@ -1,68 +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. -*/ - -'use strict'; - -// MODULES // - -var open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Synchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @returns {(integer|Error)} file descriptor or an error -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -function openSync( path, flags, mode ) { - var nargs; - var fd; - - nargs = arguments.length; - try { - if ( nargs === 1 ) { - fd = open( path, defaults.flags, defaults.mode ); - } else if ( nargs === 2 ) { - fd = open( path, flags, defaults.mode ); - } else { - fd = open( path, flags, mode ); - } - } catch ( err ) { - return err; - } - return fd; -} - - -// EXPORTS // - -module.exports = openSync; diff --git a/package.json b/package.json index 2e09ca2..35358b5 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Open a file.", "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/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.0.x", - "@stdlib/assert-is-error": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/fs-close": "^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", "stdfs", @@ -82,4 +30,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..e775d32 --- /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 7d5a851..0000000 --- a/test/test.js +++ /dev/null @@ -1,38 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is a function to open a file synchronously', function test( t ) { - t.equal( typeof open.sync, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index b58a6e1..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,110 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/main.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - open( __filename, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - open( __filename, 'r+', onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - open( __filename, 'r+', 438, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - open( 'beepboopbapbop', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', 438, onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); diff --git a/test/test.sync.js b/test/test.sync.js deleted file mode 100644 index 5132589..0000000 --- a/test/test.sync.js +++ /dev/null @@ -1,83 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/sync.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - var fd = open( __filename ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - var fd = open( __filename, 'r+' ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - var fd = open( __filename, 'r+', 438 ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - var fd = open( 'beepboopbapbop' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+', 438 ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); From f7868d128d7e42636a876b70f8839640a140f9e8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 03:19:48 +0000 Subject: [PATCH 011/113] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 4cb01c7..2e09ca2 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", + "@stdlib/error-tools-fmtprodmsg": "^0.0.x" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.0.x", @@ -81,4 +82,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} +} \ No newline at end of file From ff53cdd9df4dcabbe507ad533d98106be15bd68c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 19:40:42 +0000 Subject: [PATCH 012/113] Remove files --- index.d.ts | 150 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4044 ------------------------------------------------- 4 files changed, 4199 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 c6e863c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,150 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Buffer } from 'buffer'; - -/** -* Callback invoked after opening a file. -* -* @param err - error argument -* @param fd - file descriptor -*/ -type Callback = ( err: Error, fd: number ) => void; - -/** -* Interface for opening a file. -*/ -interface Open { - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', 438, onOpen ); - */ - ( path: string | Buffer, flags: string | number, mode: number, clbk: Callback ): void; // tslint-disable-line max-line-length - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', onOpen ); - */ - ( path: string | Buffer, flags: string | number, clbk: Callback ): void; - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, onOpen ); - */ - ( path: string | Buffer, clbk: Callback ): void; - - /** - * Synchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @returns file descriptor or an error - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * var fd = open.sync( __filename, 'r+' ); - * if ( fd instanceof Error ) { - * throw fd; - * } - * closeSync( fd ); - */ - sync( path: string | Buffer, flags?: string | number, mode?: number ): number | Error; // tslint-disable-line max-line-length -} - -/** -* Asynchronously opens a file. -* -* @param path - file path -* @param flags - file system flags (default: 'r') -* @param mode - file mode (default: 0o666) -* @param clbk - callback to invoke after opening a file -* -* @example -* var closeSync = require( `@stdlib/fs/close` ).sync; -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( `@stdlib/fs/close` ).sync; -* -* var fd = open.sync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -declare var open: Open; - - -// EXPORTS // - -export = open; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 3b5cb44..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/utils-define-nonenumerable-read-only-property@esm/index.mjs";function t(e){var t=e.default;if("function"==typeof t){var r=function(){return t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var r=t(Object.freeze({__proto__:null,default:{}})),n="r",o=438,u=r.open;function c(e,t,r,c){var a=arguments.length;return 2===a?u(e,n,o,t):3===a?u(e,t,o,r):void u(e,t,r,c)}var a=r.openSync;function i(e,t,r){var u,c;u=arguments.length;try{c=1===u?a(e,n,o):a(e,t,2===u?o:r)}catch(e){return e}return c}e(c,"sync",i);export{c as default,i as sync}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 7e37074..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;shBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAIzB,CAFC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index e775d32..0000000 --- a/stats.html +++ /dev/null @@ -1,4044 +0,0 @@ - - - - - - - - RollUp Visualizer - - - -
- - - - - From 78c6457f5ea68cbf58babf20591ea10aead8a790 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Feb 2023 19:41:18 +0000 Subject: [PATCH 013/113] 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 | 53 +- benchmark/benchmark.js | 77 - branches.md | 53 - docs/repl.txt | 65 - docs/types/test.ts | 129 - examples/index.js | 56 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/defaults.json | 4 - lib/index.js | 63 - lib/main.js | 64 - lib/sync.js | 68 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 38 - test/test.main.js | 110 - test/test.sync.js | 83 - 41 files changed, 6211 insertions(+), 3833 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/defaults.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/sync.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.sync.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 b0864be..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-02-01T00:39:22.602Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index a3a4470..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/fs/open) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 5eb1ff1..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/fs/open) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 3201e5c..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: '14 2 * * 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 + + ```
@@ -212,7 +211,7 @@ function onOpen( error, fd ) { ## 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]. @@ -276,11 +275,11 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close +[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close/tree/esm -[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists +[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists/tree/esm -[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file +[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 567aec3..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,77 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var closeSync = require( '@stdlib/fs-close' ).sync; -var pkg = require( './../package.json' ).name; -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return open( __filename, 'r+', done ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function done( error, fd ) { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - if ( error ) { - b.fail( error.message ); - } - next(); - } -}); - -bench( pkg+':sync', function benchmark( b ) { - var fd; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - fd = open.sync( __filename, 'r+' ); - if ( fd instanceof Error ) { - b.fail( fd.message ); - } else { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - } - } - b.toc(); - if ( fd instanceof Error ) { - b.fail( 'something went wrong' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 8f17b03..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/fs/open" -click B href "https://github.com/stdlib-js/fs-open/tree/main" -click C href "https://github.com/stdlib-js/fs-open/tree/production" -click D href "https://github.com/stdlib-js/fs-open/tree/esm" -click E href "https://github.com/stdlib-js/fs-open/tree/deno" -click F href "https://github.com/stdlib-js/fs-open/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/fs/open -[production-url]: https://github.com/stdlib-js/fs-open/tree/production -[deno-url]: https://github.com/stdlib-js/fs-open/tree/deno -[umd-url]: https://github.com/stdlib-js/fs-open/tree/umd -[esm-url]: https://github.com/stdlib-js/fs-open/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4cbf7ac..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,65 +0,0 @@ - -{{alias}}( path[, flags[, mode]], clbk ) - Asynchronously opens a file. - - Some characters, such as <>:"/\|?*, are reserved under Windows. - Under NTFS, if the path contains a colon, Node.js will open a file system - stream. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - clbk: Function - Callback to invoke upon opening a file. - - Examples - -------- - > function onOpen( error, fd ) { - ... if ( error ) { - ... console.error( error.message ); - ... } else { - ... {{alias:@stdlib/fs/close}}.sync( fd ); - ... } - ... }; - > {{alias}}( './beep/boop.txt', onOpen ); - - -{{alias}}.sync( path[, flags[, mode]] ) - Synchronously opens a file. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - Returns - ------- - fd: Error|integer - File descriptor. - - Examples - -------- - > var fd = {{alias}}.sync( './beep/boop.txt' ); - > if ( !{{alias:@stdlib/assert/is-error}}( fd ) ) { {{alias:@stdlib/fs/close}}.sync( fd ); }; - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 67907a2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,129 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 open = require( './index' ); - -const done = ( error: Error, fd: number ) => { - if ( error || !fd ) { - throw error; - } -}; - - -// TESTS // - -// The function does not have a return value... -{ - open( '/path/to/beepboop', done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a string... -{ - open( 123, done ); // $ExpectError - open( false, done ); // $ExpectError - open( true, done ); // $ExpectError - open( null, done ); // $ExpectError - open( undefined, done ); // $ExpectError - open( [], done ); // $ExpectError - open( {}, done ); // $ExpectError - open( ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a last argument which is not a function with the expected signature... -{ - open( '/path/to/beepboop', 'abc' ); // $ExpectError - open( '/path/to/beepboop', 123 ); // $ExpectError - open( '/path/to/beepboop', false ); // $ExpectError - open( '/path/to/beepboop', true ); // $ExpectError - open( '/path/to/beepboop', null ); // $ExpectError - open( '/path/to/beepboop', undefined ); // $ExpectError - open( '/path/to/beepboop', [] ); // $ExpectError - open( '/path/to/beepboop', {} ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `flags` argument which is not a string or number... -{ - open( '/path/to/beepboop', false, done ); // $ExpectError - open( '/path/to/beepboop', true, done ); // $ExpectError - open( '/path/to/beepboop', null, done ); // $ExpectError - open( '/path/to/beepboop', undefined, done ); // $ExpectError - open( '/path/to/beepboop', [], done ); // $ExpectError - open( '/path/to/beepboop', {}, done ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` argument which is not a number... -{ - open( '/path/to/beepboop', 'r+', 'abc', done ); // $ExpectError - open( '/path/to/beepboop', 'r+', false, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', true, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', null, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', undefined, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', [], done ); // $ExpectError - open( '/path/to/beepboop', 'r+', {}, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - open(); // $ExpectError - open( 'C:\\foo\\bar\\baz' ); // $ExpectError -} - -// Attached to main export is a `sync` method which returns a number or an error... -{ - open.sync( '/path/to/beepboop' ); // $ExpectType number | Error -} - -// The compiler throws an error if the `sync` method is provided a first argument which is not a string... -{ - open.sync( 123 ); // $ExpectError - open.sync( false ); // $ExpectError - open.sync( true ); // $ExpectError - open.sync( null ); // $ExpectError - open.sync( undefined ); // $ExpectError - open.sync( [] ); // $ExpectError - open.sync( {} ); // $ExpectError - open.sync( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a second argument which is not a string or number... -{ - open.sync( '/path/to/beepboop', false ); // $ExpectError - open.sync( '/path/to/beepboop', true ); // $ExpectError - open.sync( '/path/to/beepboop', null ); // $ExpectError - open.sync( '/path/to/beepboop', [] ); // $ExpectError - open.sync( '/path/to/beepboop', {} ); // $ExpectError - open.sync( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a third argument which is not a number... -{ - open.sync( '/path/to/beepboop', 'r+', false ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', true ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', null ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', [] ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', {} ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided an unsupported number of arguments... -{ - open.sync(); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 71359fe..0000000 --- a/examples/index.js +++ /dev/null @@ -1,56 +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. -*/ - -'use strict'; - -var closeSync = require( '@stdlib/fs-close' ).sync; -var isError = require( '@stdlib/assert-is-error' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - -/* Sync */ - -var fd = open.sync( __filename, 'r+' ); -// returns - -console.log( isError( fd ) ); -// => false - -closeSync( fd ); - -fd = open.sync( 'beepboop' ); -// returns - -console.log( isError( fd ) ); -// => true - -/* Async */ - -open( __filename, onOpen ); -open( 'beepboop', onOpen ); - -function onOpen( error, fd ) { - if ( error ) { - if ( error.code === 'ENOENT' ) { - console.error( 'File does not exist.' ); - } else { - throw error; - } - } else { - closeSync( fd ); - } -} 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..bdb76ee --- /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/utils-define-nonenumerable-read-only-property@esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){if(this instanceof e){var n=[null];n.push.apply(n,arguments);var r=Function.bind.apply(t,n);return new r}return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}var n=t(Object.freeze({__proto__:null,default:{}})),r="r",o=438,u=n.open;function i(e,t,n,i){var a=arguments.length;return 2===a?u(e,r,o,t):3===a?u(e,t,o,n):void u(e,t,n,i)}var a=n.openSync;function p(e,t,n){var u,i;u=arguments.length;try{i=1===u?a(e,r,o):a(e,t,2===u?o:n)}catch(e){return e}return i}e(i,"sync",p);export{i as default,p as sync}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..e41289c --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;0pBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAIzB,CAFC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index cb174b7..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "flags": "r", - "mode": 438 -} diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 8edd6de..0000000 --- a/lib/index.js +++ /dev/null @@ -1,63 +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. -*/ - -'use strict'; - -/** -* Open a file. -* -* @module @stdlib/fs-open -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var openSync = require( '@stdlib/fs-open' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var sync = require( './sync.js' ); - - -// MAIN // - -setReadOnly( main, 'sync', sync ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index feb5171..0000000 --- a/lib/main.js +++ /dev/null @@ -1,64 +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. -*/ - -'use strict'; - -// MODULES // - -var op = require( 'fs' ).open; -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Asynchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @param {Function} clbk - callback to invoke after opening a file -* @returns {void} -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -*/ -function open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare - var nargs = arguments.length; - if ( nargs === 2 ) { - return op( path, defaults.flags, defaults.mode, flags ); - } - if ( nargs === 3 ) { - return op( path, flags, defaults.mode, mode ); - } - op( path, flags, mode, clbk ); -} - - -// EXPORTS // - -module.exports = open; diff --git a/lib/sync.js b/lib/sync.js deleted file mode 100644 index d8d2e00..0000000 --- a/lib/sync.js +++ /dev/null @@ -1,68 +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. -*/ - -'use strict'; - -// MODULES // - -var open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Synchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @returns {(integer|Error)} file descriptor or an error -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -function openSync( path, flags, mode ) { - var nargs; - var fd; - - nargs = arguments.length; - try { - if ( nargs === 1 ) { - fd = open( path, defaults.flags, defaults.mode ); - } else if ( nargs === 2 ) { - fd = open( path, flags, defaults.mode ); - } else { - fd = open( path, flags, mode ); - } - } catch ( err ) { - return err; - } - return fd; -} - - -// EXPORTS // - -module.exports = openSync; diff --git a/package.json b/package.json index 2e09ca2..35358b5 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Open a file.", "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/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/error-tools-fmtprodmsg": "^0.0.x" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.0.x", - "@stdlib/assert-is-error": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/fs-close": "^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", "stdfs", @@ -82,4 +30,4 @@ "type": "patreon", "url": "https://www.patreon.com/athan" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..1cc910f --- /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 7d5a851..0000000 --- a/test/test.js +++ /dev/null @@ -1,38 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is a function to open a file synchronously', function test( t ) { - t.equal( typeof open.sync, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index b58a6e1..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,110 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/main.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - open( __filename, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - open( __filename, 'r+', onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - open( __filename, 'r+', 438, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - open( 'beepboopbapbop', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', 438, onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); diff --git a/test/test.sync.js b/test/test.sync.js deleted file mode 100644 index 5132589..0000000 --- a/test/test.sync.js +++ /dev/null @@ -1,83 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/sync.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - var fd = open( __filename ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - var fd = open( __filename, 'r+' ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - var fd = open( __filename, 'r+', 438 ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - var fd = open( 'beepboopbapbop' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+', 438 ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); From 6ab5528103270619bcb908b6404285a8a2958223 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Mar 2023 01:00:21 +0000 Subject: [PATCH 014/113] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ba6867a..94dff5d 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.0.8", @@ -81,4 +82,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From f5e64b8b60a0650a948eceebca2b110a696b7008 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Mar 2023 02:09:13 +0000 Subject: [PATCH 015/113] Remove files --- index.d.ts | 150 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6332 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 c6e863c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,150 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Buffer } from 'buffer'; - -/** -* Callback invoked after opening a file. -* -* @param err - error argument -* @param fd - file descriptor -*/ -type Callback = ( err: Error, fd: number ) => void; - -/** -* Interface for opening a file. -*/ -interface Open { - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', 438, onOpen ); - */ - ( path: string | Buffer, flags: string | number, mode: number, clbk: Callback ): void; // tslint-disable-line max-line-length - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', onOpen ); - */ - ( path: string | Buffer, flags: string | number, clbk: Callback ): void; - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, onOpen ); - */ - ( path: string | Buffer, clbk: Callback ): void; - - /** - * Synchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @returns file descriptor or an error - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * var fd = open.sync( __filename, 'r+' ); - * if ( fd instanceof Error ) { - * throw fd; - * } - * closeSync( fd ); - */ - sync( path: string | Buffer, flags?: string | number, mode?: number ): number | Error; // tslint-disable-line max-line-length -} - -/** -* Asynchronously opens a file. -* -* @param path - file path -* @param flags - file system flags (default: 'r') -* @param mode - file mode (default: 0o666) -* @param clbk - callback to invoke after opening a file -* -* @example -* var closeSync = require( `@stdlib/fs/close` ).sync; -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( `@stdlib/fs/close` ).sync; -* -* var fd = open.sync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -declare var open: Open; - - -// EXPORTS // - -export = open; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index bdb76ee..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/utils-define-nonenumerable-read-only-property@esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){if(this instanceof e){var n=[null];n.push.apply(n,arguments);var r=Function.bind.apply(t,n);return new r}return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}var n=t(Object.freeze({__proto__:null,default:{}})),r="r",o=438,u=n.open;function i(e,t,n,i){var a=arguments.length;return 2===a?u(e,r,o,t):3===a?u(e,t,o,n):void u(e,t,n,i)}var a=n.openSync;function p(e,t,n){var u,i;u=arguments.length;try{i=1===u?a(e,r,o):a(e,t,2===u?o:n)}catch(e){return e}return i}e(i,"sync",p);export{i as default,p as sync}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index e41289c..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;0pBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAIzB,CAFC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 1cc910f..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From bb8c8eb0a48cdd576fafcc8d7ec07e5f643d2eee Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Mar 2023 02:10:01 +0000 Subject: [PATCH 016/113] 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 | 53 +- benchmark/benchmark.js | 77 - branches.md | 53 - docs/repl.txt | 65 - docs/types/test.ts | 129 - examples/index.js | 56 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/defaults.json | 4 - lib/index.js | 63 - lib/main.js | 64 - lib/sync.js | 68 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 38 - test/test.main.js | 110 - test/test.sync.js | 83 - 41 files changed, 6211 insertions(+), 3968 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/defaults.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/sync.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.sync.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 aae8a8c..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-03-01T00:48:05.903Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index a3a4470..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/fs/open) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 5eb1ff1..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/fs/open) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 3201e5c..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: '14 2 * * 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 + + ```
@@ -212,7 +211,7 @@ function onOpen( error, fd ) { ## 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]. @@ -276,11 +275,11 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close +[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close/tree/esm -[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists +[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists/tree/esm -[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file +[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 567aec3..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,77 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var closeSync = require( '@stdlib/fs-close' ).sync; -var pkg = require( './../package.json' ).name; -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return open( __filename, 'r+', done ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function done( error, fd ) { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - if ( error ) { - b.fail( error.message ); - } - next(); - } -}); - -bench( pkg+':sync', function benchmark( b ) { - var fd; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - fd = open.sync( __filename, 'r+' ); - if ( fd instanceof Error ) { - b.fail( fd.message ); - } else { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - } - } - b.toc(); - if ( fd instanceof Error ) { - b.fail( 'something went wrong' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index fa29fdf..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/fs/open" -%% click B href "https://github.com/stdlib-js/fs-open/tree/main" -%% click C href "https://github.com/stdlib-js/fs-open/tree/production" -%% click D href "https://github.com/stdlib-js/fs-open/tree/esm" -%% click E href "https://github.com/stdlib-js/fs-open/tree/deno" -%% click F href "https://github.com/stdlib-js/fs-open/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/fs/open -[production-url]: https://github.com/stdlib-js/fs-open/tree/production -[deno-url]: https://github.com/stdlib-js/fs-open/tree/deno -[umd-url]: https://github.com/stdlib-js/fs-open/tree/umd -[esm-url]: https://github.com/stdlib-js/fs-open/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4cbf7ac..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,65 +0,0 @@ - -{{alias}}( path[, flags[, mode]], clbk ) - Asynchronously opens a file. - - Some characters, such as <>:"/\|?*, are reserved under Windows. - Under NTFS, if the path contains a colon, Node.js will open a file system - stream. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - clbk: Function - Callback to invoke upon opening a file. - - Examples - -------- - > function onOpen( error, fd ) { - ... if ( error ) { - ... console.error( error.message ); - ... } else { - ... {{alias:@stdlib/fs/close}}.sync( fd ); - ... } - ... }; - > {{alias}}( './beep/boop.txt', onOpen ); - - -{{alias}}.sync( path[, flags[, mode]] ) - Synchronously opens a file. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - Returns - ------- - fd: Error|integer - File descriptor. - - Examples - -------- - > var fd = {{alias}}.sync( './beep/boop.txt' ); - > if ( !{{alias:@stdlib/assert/is-error}}( fd ) ) { {{alias:@stdlib/fs/close}}.sync( fd ); }; - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 67907a2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,129 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 open = require( './index' ); - -const done = ( error: Error, fd: number ) => { - if ( error || !fd ) { - throw error; - } -}; - - -// TESTS // - -// The function does not have a return value... -{ - open( '/path/to/beepboop', done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a string... -{ - open( 123, done ); // $ExpectError - open( false, done ); // $ExpectError - open( true, done ); // $ExpectError - open( null, done ); // $ExpectError - open( undefined, done ); // $ExpectError - open( [], done ); // $ExpectError - open( {}, done ); // $ExpectError - open( ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a last argument which is not a function with the expected signature... -{ - open( '/path/to/beepboop', 'abc' ); // $ExpectError - open( '/path/to/beepboop', 123 ); // $ExpectError - open( '/path/to/beepboop', false ); // $ExpectError - open( '/path/to/beepboop', true ); // $ExpectError - open( '/path/to/beepboop', null ); // $ExpectError - open( '/path/to/beepboop', undefined ); // $ExpectError - open( '/path/to/beepboop', [] ); // $ExpectError - open( '/path/to/beepboop', {} ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `flags` argument which is not a string or number... -{ - open( '/path/to/beepboop', false, done ); // $ExpectError - open( '/path/to/beepboop', true, done ); // $ExpectError - open( '/path/to/beepboop', null, done ); // $ExpectError - open( '/path/to/beepboop', undefined, done ); // $ExpectError - open( '/path/to/beepboop', [], done ); // $ExpectError - open( '/path/to/beepboop', {}, done ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` argument which is not a number... -{ - open( '/path/to/beepboop', 'r+', 'abc', done ); // $ExpectError - open( '/path/to/beepboop', 'r+', false, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', true, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', null, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', undefined, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', [], done ); // $ExpectError - open( '/path/to/beepboop', 'r+', {}, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - open(); // $ExpectError - open( 'C:\\foo\\bar\\baz' ); // $ExpectError -} - -// Attached to main export is a `sync` method which returns a number or an error... -{ - open.sync( '/path/to/beepboop' ); // $ExpectType number | Error -} - -// The compiler throws an error if the `sync` method is provided a first argument which is not a string... -{ - open.sync( 123 ); // $ExpectError - open.sync( false ); // $ExpectError - open.sync( true ); // $ExpectError - open.sync( null ); // $ExpectError - open.sync( undefined ); // $ExpectError - open.sync( [] ); // $ExpectError - open.sync( {} ); // $ExpectError - open.sync( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a second argument which is not a string or number... -{ - open.sync( '/path/to/beepboop', false ); // $ExpectError - open.sync( '/path/to/beepboop', true ); // $ExpectError - open.sync( '/path/to/beepboop', null ); // $ExpectError - open.sync( '/path/to/beepboop', [] ); // $ExpectError - open.sync( '/path/to/beepboop', {} ); // $ExpectError - open.sync( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a third argument which is not a number... -{ - open.sync( '/path/to/beepboop', 'r+', false ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', true ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', null ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', [] ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', {} ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided an unsupported number of arguments... -{ - open.sync(); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 71359fe..0000000 --- a/examples/index.js +++ /dev/null @@ -1,56 +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. -*/ - -'use strict'; - -var closeSync = require( '@stdlib/fs-close' ).sync; -var isError = require( '@stdlib/assert-is-error' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - -/* Sync */ - -var fd = open.sync( __filename, 'r+' ); -// returns - -console.log( isError( fd ) ); -// => false - -closeSync( fd ); - -fd = open.sync( 'beepboop' ); -// returns - -console.log( isError( fd ) ); -// => true - -/* Async */ - -open( __filename, onOpen ); -open( 'beepboop', onOpen ); - -function onOpen( error, fd ) { - if ( error ) { - if ( error.code === 'ENOENT' ) { - console.error( 'File does not exist.' ); - } else { - throw error; - } - } else { - closeSync( fd ); - } -} 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..bdb76ee --- /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/utils-define-nonenumerable-read-only-property@esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){if(this instanceof e){var n=[null];n.push.apply(n,arguments);var r=Function.bind.apply(t,n);return new r}return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}var n=t(Object.freeze({__proto__:null,default:{}})),r="r",o=438,u=n.open;function i(e,t,n,i){var a=arguments.length;return 2===a?u(e,r,o,t):3===a?u(e,t,o,n):void u(e,t,n,i)}var a=n.openSync;function p(e,t,n){var u,i;u=arguments.length;try{i=1===u?a(e,r,o):a(e,t,2===u?o:n)}catch(e){return e}return i}e(i,"sync",p);export{i as default,p as sync}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..e41289c --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;0pBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAIzB,CAFC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index cb174b7..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "flags": "r", - "mode": 438 -} diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 8edd6de..0000000 --- a/lib/index.js +++ /dev/null @@ -1,63 +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. -*/ - -'use strict'; - -/** -* Open a file. -* -* @module @stdlib/fs-open -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var openSync = require( '@stdlib/fs-open' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var sync = require( './sync.js' ); - - -// MAIN // - -setReadOnly( main, 'sync', sync ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index feb5171..0000000 --- a/lib/main.js +++ /dev/null @@ -1,64 +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. -*/ - -'use strict'; - -// MODULES // - -var op = require( 'fs' ).open; -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Asynchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @param {Function} clbk - callback to invoke after opening a file -* @returns {void} -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -*/ -function open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare - var nargs = arguments.length; - if ( nargs === 2 ) { - return op( path, defaults.flags, defaults.mode, flags ); - } - if ( nargs === 3 ) { - return op( path, flags, defaults.mode, mode ); - } - op( path, flags, mode, clbk ); -} - - -// EXPORTS // - -module.exports = open; diff --git a/lib/sync.js b/lib/sync.js deleted file mode 100644 index d8d2e00..0000000 --- a/lib/sync.js +++ /dev/null @@ -1,68 +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. -*/ - -'use strict'; - -// MODULES // - -var open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Synchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @returns {(integer|Error)} file descriptor or an error -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -function openSync( path, flags, mode ) { - var nargs; - var fd; - - nargs = arguments.length; - try { - if ( nargs === 1 ) { - fd = open( path, defaults.flags, defaults.mode ); - } else if ( nargs === 2 ) { - fd = open( path, flags, defaults.mode ); - } else { - fd = open( path, flags, mode ); - } - } catch ( err ) { - return err; - } - return fd; -} - - -// EXPORTS // - -module.exports = openSync; diff --git a/package.json b/package.json index 94dff5d..20ba9d3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Open a file.", "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/utils-define-nonenumerable-read-only-property": "^0.0.7", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.0.8", - "@stdlib/assert-is-error": "^0.0.8", - "@stdlib/assert-is-nonnegative-integer": "^0.0.7", - "@stdlib/bench": "^0.0.12", - "@stdlib/fs-close": "^0.0.7", - "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", "stdfs", @@ -82,4 +30,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..28a437d --- /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 7d5a851..0000000 --- a/test/test.js +++ /dev/null @@ -1,38 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is a function to open a file synchronously', function test( t ) { - t.equal( typeof open.sync, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index b58a6e1..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,110 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/main.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - open( __filename, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - open( __filename, 'r+', onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - open( __filename, 'r+', 438, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - open( 'beepboopbapbop', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', 438, onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); diff --git a/test/test.sync.js b/test/test.sync.js deleted file mode 100644 index 5132589..0000000 --- a/test/test.sync.js +++ /dev/null @@ -1,83 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/sync.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - var fd = open( __filename ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - var fd = open( __filename, 'r+' ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - var fd = open( __filename, 'r+', 438 ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - var fd = open( 'beepboopbapbop' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+', 438 ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); From 64350b565da176a026a33a680a8600c28db2391e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Apr 2023 00:58:18 +0000 Subject: [PATCH 017/113] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ba6867a..94dff5d 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.0.8", @@ -81,4 +82,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 0a2c1c03153610d3268d32493d05621d6af3ea54 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Apr 2023 02:00:38 +0000 Subject: [PATCH 018/113] Remove files --- index.d.ts | 150 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6332 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 c6e863c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,150 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Buffer } from 'buffer'; - -/** -* Callback invoked after opening a file. -* -* @param err - error argument -* @param fd - file descriptor -*/ -type Callback = ( err: Error, fd: number ) => void; - -/** -* Interface for opening a file. -*/ -interface Open { - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', 438, onOpen ); - */ - ( path: string | Buffer, flags: string | number, mode: number, clbk: Callback ): void; // tslint-disable-line max-line-length - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', onOpen ); - */ - ( path: string | Buffer, flags: string | number, clbk: Callback ): void; - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, onOpen ); - */ - ( path: string | Buffer, clbk: Callback ): void; - - /** - * Synchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @returns file descriptor or an error - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * var fd = open.sync( __filename, 'r+' ); - * if ( fd instanceof Error ) { - * throw fd; - * } - * closeSync( fd ); - */ - sync( path: string | Buffer, flags?: string | number, mode?: number ): number | Error; // tslint-disable-line max-line-length -} - -/** -* Asynchronously opens a file. -* -* @param path - file path -* @param flags - file system flags (default: 'r') -* @param mode - file mode (default: 0o666) -* @param clbk - callback to invoke after opening a file -* -* @example -* var closeSync = require( `@stdlib/fs/close` ).sync; -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( `@stdlib/fs/close` ).sync; -* -* var fd = open.sync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -declare var open: Open; - - -// EXPORTS // - -export = open; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index bdb76ee..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/utils-define-nonenumerable-read-only-property@esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){if(this instanceof e){var n=[null];n.push.apply(n,arguments);var r=Function.bind.apply(t,n);return new r}return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}var n=t(Object.freeze({__proto__:null,default:{}})),r="r",o=438,u=n.open;function i(e,t,n,i){var a=arguments.length;return 2===a?u(e,r,o,t):3===a?u(e,t,o,n):void u(e,t,n,i)}var a=n.openSync;function p(e,t,n){var u,i;u=arguments.length;try{i=1===u?a(e,r,o):a(e,t,2===u?o:n)}catch(e){return e}return i}e(i,"sync",p);export{i as default,p as sync}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index e41289c..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;0pBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAIzB,CAFC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 28a437d..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 9905ef7cc1c171d6ced4e96d503644ecf9e9caf0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Apr 2023 02:01:16 +0000 Subject: [PATCH 019/113] 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 | 53 +- benchmark/benchmark.js | 77 - branches.md | 53 - docs/repl.txt | 65 - docs/types/test.ts | 129 - examples/index.js | 56 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/defaults.json | 4 - lib/index.js | 63 - lib/main.js | 64 - lib/sync.js | 68 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 38 - test/test.main.js | 110 - test/test.sync.js | 83 - 41 files changed, 6211 insertions(+), 3974 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/defaults.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/sync.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.sync.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 1a35ed5..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-04-01T00:46:14.633Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index a3a4470..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/fs/open) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 5eb1ff1..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/fs/open) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 3201e5c..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: '14 2 * * 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 + + ```
@@ -212,7 +211,7 @@ function onOpen( error, fd ) { ## 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]. @@ -276,11 +275,11 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close +[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close/tree/esm -[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists +[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists/tree/esm -[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file +[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 567aec3..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,77 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var closeSync = require( '@stdlib/fs-close' ).sync; -var pkg = require( './../package.json' ).name; -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return open( __filename, 'r+', done ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function done( error, fd ) { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - if ( error ) { - b.fail( error.message ); - } - next(); - } -}); - -bench( pkg+':sync', function benchmark( b ) { - var fd; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - fd = open.sync( __filename, 'r+' ); - if ( fd instanceof Error ) { - b.fail( fd.message ); - } else { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - } - } - b.toc(); - if ( fd instanceof Error ) { - b.fail( 'something went wrong' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index fa29fdf..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/fs/open" -%% click B href "https://github.com/stdlib-js/fs-open/tree/main" -%% click C href "https://github.com/stdlib-js/fs-open/tree/production" -%% click D href "https://github.com/stdlib-js/fs-open/tree/esm" -%% click E href "https://github.com/stdlib-js/fs-open/tree/deno" -%% click F href "https://github.com/stdlib-js/fs-open/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/fs/open -[production-url]: https://github.com/stdlib-js/fs-open/tree/production -[deno-url]: https://github.com/stdlib-js/fs-open/tree/deno -[umd-url]: https://github.com/stdlib-js/fs-open/tree/umd -[esm-url]: https://github.com/stdlib-js/fs-open/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4cbf7ac..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,65 +0,0 @@ - -{{alias}}( path[, flags[, mode]], clbk ) - Asynchronously opens a file. - - Some characters, such as <>:"/\|?*, are reserved under Windows. - Under NTFS, if the path contains a colon, Node.js will open a file system - stream. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - clbk: Function - Callback to invoke upon opening a file. - - Examples - -------- - > function onOpen( error, fd ) { - ... if ( error ) { - ... console.error( error.message ); - ... } else { - ... {{alias:@stdlib/fs/close}}.sync( fd ); - ... } - ... }; - > {{alias}}( './beep/boop.txt', onOpen ); - - -{{alias}}.sync( path[, flags[, mode]] ) - Synchronously opens a file. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - Returns - ------- - fd: Error|integer - File descriptor. - - Examples - -------- - > var fd = {{alias}}.sync( './beep/boop.txt' ); - > if ( !{{alias:@stdlib/assert/is-error}}( fd ) ) { {{alias:@stdlib/fs/close}}.sync( fd ); }; - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 67907a2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,129 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 open = require( './index' ); - -const done = ( error: Error, fd: number ) => { - if ( error || !fd ) { - throw error; - } -}; - - -// TESTS // - -// The function does not have a return value... -{ - open( '/path/to/beepboop', done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a string... -{ - open( 123, done ); // $ExpectError - open( false, done ); // $ExpectError - open( true, done ); // $ExpectError - open( null, done ); // $ExpectError - open( undefined, done ); // $ExpectError - open( [], done ); // $ExpectError - open( {}, done ); // $ExpectError - open( ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a last argument which is not a function with the expected signature... -{ - open( '/path/to/beepboop', 'abc' ); // $ExpectError - open( '/path/to/beepboop', 123 ); // $ExpectError - open( '/path/to/beepboop', false ); // $ExpectError - open( '/path/to/beepboop', true ); // $ExpectError - open( '/path/to/beepboop', null ); // $ExpectError - open( '/path/to/beepboop', undefined ); // $ExpectError - open( '/path/to/beepboop', [] ); // $ExpectError - open( '/path/to/beepboop', {} ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `flags` argument which is not a string or number... -{ - open( '/path/to/beepboop', false, done ); // $ExpectError - open( '/path/to/beepboop', true, done ); // $ExpectError - open( '/path/to/beepboop', null, done ); // $ExpectError - open( '/path/to/beepboop', undefined, done ); // $ExpectError - open( '/path/to/beepboop', [], done ); // $ExpectError - open( '/path/to/beepboop', {}, done ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` argument which is not a number... -{ - open( '/path/to/beepboop', 'r+', 'abc', done ); // $ExpectError - open( '/path/to/beepboop', 'r+', false, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', true, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', null, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', undefined, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', [], done ); // $ExpectError - open( '/path/to/beepboop', 'r+', {}, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - open(); // $ExpectError - open( 'C:\\foo\\bar\\baz' ); // $ExpectError -} - -// Attached to main export is a `sync` method which returns a number or an error... -{ - open.sync( '/path/to/beepboop' ); // $ExpectType number | Error -} - -// The compiler throws an error if the `sync` method is provided a first argument which is not a string... -{ - open.sync( 123 ); // $ExpectError - open.sync( false ); // $ExpectError - open.sync( true ); // $ExpectError - open.sync( null ); // $ExpectError - open.sync( undefined ); // $ExpectError - open.sync( [] ); // $ExpectError - open.sync( {} ); // $ExpectError - open.sync( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a second argument which is not a string or number... -{ - open.sync( '/path/to/beepboop', false ); // $ExpectError - open.sync( '/path/to/beepboop', true ); // $ExpectError - open.sync( '/path/to/beepboop', null ); // $ExpectError - open.sync( '/path/to/beepboop', [] ); // $ExpectError - open.sync( '/path/to/beepboop', {} ); // $ExpectError - open.sync( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a third argument which is not a number... -{ - open.sync( '/path/to/beepboop', 'r+', false ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', true ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', null ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', [] ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', {} ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided an unsupported number of arguments... -{ - open.sync(); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 71359fe..0000000 --- a/examples/index.js +++ /dev/null @@ -1,56 +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. -*/ - -'use strict'; - -var closeSync = require( '@stdlib/fs-close' ).sync; -var isError = require( '@stdlib/assert-is-error' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - -/* Sync */ - -var fd = open.sync( __filename, 'r+' ); -// returns - -console.log( isError( fd ) ); -// => false - -closeSync( fd ); - -fd = open.sync( 'beepboop' ); -// returns - -console.log( isError( fd ) ); -// => true - -/* Async */ - -open( __filename, onOpen ); -open( 'beepboop', onOpen ); - -function onOpen( error, fd ) { - if ( error ) { - if ( error.code === 'ENOENT' ) { - console.error( 'File does not exist.' ); - } else { - throw error; - } - } else { - closeSync( fd ); - } -} 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..bdb76ee --- /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/utils-define-nonenumerable-read-only-property@esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){if(this instanceof e){var n=[null];n.push.apply(n,arguments);var r=Function.bind.apply(t,n);return new r}return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}var n=t(Object.freeze({__proto__:null,default:{}})),r="r",o=438,u=n.open;function i(e,t,n,i){var a=arguments.length;return 2===a?u(e,r,o,t):3===a?u(e,t,o,n):void u(e,t,n,i)}var a=n.openSync;function p(e,t,n){var u,i;u=arguments.length;try{i=1===u?a(e,r,o):a(e,t,2===u?o:n)}catch(e){return e}return i}e(i,"sync",p);export{i as default,p as sync}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..e41289c --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;0pBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAIzB,CAFC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index cb174b7..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "flags": "r", - "mode": 438 -} diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 8edd6de..0000000 --- a/lib/index.js +++ /dev/null @@ -1,63 +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. -*/ - -'use strict'; - -/** -* Open a file. -* -* @module @stdlib/fs-open -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var openSync = require( '@stdlib/fs-open' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var sync = require( './sync.js' ); - - -// MAIN // - -setReadOnly( main, 'sync', sync ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index feb5171..0000000 --- a/lib/main.js +++ /dev/null @@ -1,64 +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. -*/ - -'use strict'; - -// MODULES // - -var op = require( 'fs' ).open; -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Asynchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @param {Function} clbk - callback to invoke after opening a file -* @returns {void} -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -*/ -function open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare - var nargs = arguments.length; - if ( nargs === 2 ) { - return op( path, defaults.flags, defaults.mode, flags ); - } - if ( nargs === 3 ) { - return op( path, flags, defaults.mode, mode ); - } - op( path, flags, mode, clbk ); -} - - -// EXPORTS // - -module.exports = open; diff --git a/lib/sync.js b/lib/sync.js deleted file mode 100644 index d8d2e00..0000000 --- a/lib/sync.js +++ /dev/null @@ -1,68 +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. -*/ - -'use strict'; - -// MODULES // - -var open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Synchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @returns {(integer|Error)} file descriptor or an error -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -function openSync( path, flags, mode ) { - var nargs; - var fd; - - nargs = arguments.length; - try { - if ( nargs === 1 ) { - fd = open( path, defaults.flags, defaults.mode ); - } else if ( nargs === 2 ) { - fd = open( path, flags, defaults.mode ); - } else { - fd = open( path, flags, mode ); - } - } catch ( err ) { - return err; - } - return fd; -} - - -// EXPORTS // - -module.exports = openSync; diff --git a/package.json b/package.json index 94dff5d..20ba9d3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Open a file.", "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/utils-define-nonenumerable-read-only-property": "^0.0.7", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.0.8", - "@stdlib/assert-is-error": "^0.0.8", - "@stdlib/assert-is-nonnegative-integer": "^0.0.7", - "@stdlib/bench": "^0.0.12", - "@stdlib/fs-close": "^0.0.7", - "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", "stdfs", @@ -82,4 +30,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b260e81 --- /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 7d5a851..0000000 --- a/test/test.js +++ /dev/null @@ -1,38 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is a function to open a file synchronously', function test( t ) { - t.equal( typeof open.sync, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index b58a6e1..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,110 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/main.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - open( __filename, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - open( __filename, 'r+', onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - open( __filename, 'r+', 438, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - open( 'beepboopbapbop', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', 438, onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); diff --git a/test/test.sync.js b/test/test.sync.js deleted file mode 100644 index 5132589..0000000 --- a/test/test.sync.js +++ /dev/null @@ -1,83 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/sync.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - var fd = open( __filename ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - var fd = open( __filename, 'r+' ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - var fd = open( __filename, 'r+', 438 ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - var fd = open( 'beepboopbapbop' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+', 438 ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); From 8621a7b3d83c817408230f9b88986bbe9842db58 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 May 2023 00:57:18 +0000 Subject: [PATCH 020/113] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ba6867a..94dff5d 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.0.8", @@ -81,4 +82,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From fe3021fc536d3cc096b34b1972cc7cab49a960de Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 May 2023 01:59:38 +0000 Subject: [PATCH 021/113] Remove files --- index.d.ts | 150 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6332 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 c6e863c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,150 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Buffer } from 'buffer'; - -/** -* Callback invoked after opening a file. -* -* @param err - error argument -* @param fd - file descriptor -*/ -type Callback = ( err: Error, fd: number ) => void; - -/** -* Interface for opening a file. -*/ -interface Open { - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', 438, onOpen ); - */ - ( path: string | Buffer, flags: string | number, mode: number, clbk: Callback ): void; // tslint-disable-line max-line-length - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', onOpen ); - */ - ( path: string | Buffer, flags: string | number, clbk: Callback ): void; - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, onOpen ); - */ - ( path: string | Buffer, clbk: Callback ): void; - - /** - * Synchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @returns file descriptor or an error - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * var fd = open.sync( __filename, 'r+' ); - * if ( fd instanceof Error ) { - * throw fd; - * } - * closeSync( fd ); - */ - sync( path: string | Buffer, flags?: string | number, mode?: number ): number | Error; // tslint-disable-line max-line-length -} - -/** -* Asynchronously opens a file. -* -* @param path - file path -* @param flags - file system flags (default: 'r') -* @param mode - file mode (default: 0o666) -* @param clbk - callback to invoke after opening a file -* -* @example -* var closeSync = require( `@stdlib/fs/close` ).sync; -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( `@stdlib/fs/close` ).sync; -* -* var fd = open.sync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -declare var open: Open; - - -// EXPORTS // - -export = open; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index bdb76ee..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/utils-define-nonenumerable-read-only-property@esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){if(this instanceof e){var n=[null];n.push.apply(n,arguments);var r=Function.bind.apply(t,n);return new r}return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}var n=t(Object.freeze({__proto__:null,default:{}})),r="r",o=438,u=n.open;function i(e,t,n,i){var a=arguments.length;return 2===a?u(e,r,o,t):3===a?u(e,t,o,n):void u(e,t,n,i)}var a=n.openSync;function p(e,t,n){var u,i;u=arguments.length;try{i=1===u?a(e,r,o):a(e,t,2===u?o:n)}catch(e){return e}return i}e(i,"sync",p);export{i as default,p as sync}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index e41289c..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;0pBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAIzB,CAFC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b260e81..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 0362e18b94f56e4a9d170875b71a4071eccbde89 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 May 2023 02:00:26 +0000 Subject: [PATCH 022/113] 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 | 53 +- benchmark/benchmark.js | 77 - branches.md | 53 - docs/repl.txt | 65 - docs/types/test.ts | 129 - examples/index.js | 56 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/defaults.json | 4 - lib/index.js | 63 - lib/main.js | 64 - lib/sync.js | 68 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 38 - test/test.main.js | 110 - test/test.sync.js | 83 - 41 files changed, 6211 insertions(+), 3974 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/defaults.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/sync.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.sync.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 b11738a..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-05-01T00:45:27.190Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index a3a4470..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/fs/open) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 5eb1ff1..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/fs/open) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 3201e5c..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: '14 2 * * 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 + + ```
@@ -212,7 +211,7 @@ function onOpen( error, fd ) { ## 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]. @@ -276,11 +275,11 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close +[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close/tree/esm -[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists +[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists/tree/esm -[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file +[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 567aec3..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,77 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var closeSync = require( '@stdlib/fs-close' ).sync; -var pkg = require( './../package.json' ).name; -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return open( __filename, 'r+', done ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function done( error, fd ) { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - if ( error ) { - b.fail( error.message ); - } - next(); - } -}); - -bench( pkg+':sync', function benchmark( b ) { - var fd; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - fd = open.sync( __filename, 'r+' ); - if ( fd instanceof Error ) { - b.fail( fd.message ); - } else { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - } - } - b.toc(); - if ( fd instanceof Error ) { - b.fail( 'something went wrong' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index fa29fdf..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/fs/open" -%% click B href "https://github.com/stdlib-js/fs-open/tree/main" -%% click C href "https://github.com/stdlib-js/fs-open/tree/production" -%% click D href "https://github.com/stdlib-js/fs-open/tree/esm" -%% click E href "https://github.com/stdlib-js/fs-open/tree/deno" -%% click F href "https://github.com/stdlib-js/fs-open/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/fs/open -[production-url]: https://github.com/stdlib-js/fs-open/tree/production -[deno-url]: https://github.com/stdlib-js/fs-open/tree/deno -[umd-url]: https://github.com/stdlib-js/fs-open/tree/umd -[esm-url]: https://github.com/stdlib-js/fs-open/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4cbf7ac..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,65 +0,0 @@ - -{{alias}}( path[, flags[, mode]], clbk ) - Asynchronously opens a file. - - Some characters, such as <>:"/\|?*, are reserved under Windows. - Under NTFS, if the path contains a colon, Node.js will open a file system - stream. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - clbk: Function - Callback to invoke upon opening a file. - - Examples - -------- - > function onOpen( error, fd ) { - ... if ( error ) { - ... console.error( error.message ); - ... } else { - ... {{alias:@stdlib/fs/close}}.sync( fd ); - ... } - ... }; - > {{alias}}( './beep/boop.txt', onOpen ); - - -{{alias}}.sync( path[, flags[, mode]] ) - Synchronously opens a file. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - Returns - ------- - fd: Error|integer - File descriptor. - - Examples - -------- - > var fd = {{alias}}.sync( './beep/boop.txt' ); - > if ( !{{alias:@stdlib/assert/is-error}}( fd ) ) { {{alias:@stdlib/fs/close}}.sync( fd ); }; - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 67907a2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,129 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 open = require( './index' ); - -const done = ( error: Error, fd: number ) => { - if ( error || !fd ) { - throw error; - } -}; - - -// TESTS // - -// The function does not have a return value... -{ - open( '/path/to/beepboop', done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a string... -{ - open( 123, done ); // $ExpectError - open( false, done ); // $ExpectError - open( true, done ); // $ExpectError - open( null, done ); // $ExpectError - open( undefined, done ); // $ExpectError - open( [], done ); // $ExpectError - open( {}, done ); // $ExpectError - open( ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a last argument which is not a function with the expected signature... -{ - open( '/path/to/beepboop', 'abc' ); // $ExpectError - open( '/path/to/beepboop', 123 ); // $ExpectError - open( '/path/to/beepboop', false ); // $ExpectError - open( '/path/to/beepboop', true ); // $ExpectError - open( '/path/to/beepboop', null ); // $ExpectError - open( '/path/to/beepboop', undefined ); // $ExpectError - open( '/path/to/beepboop', [] ); // $ExpectError - open( '/path/to/beepboop', {} ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `flags` argument which is not a string or number... -{ - open( '/path/to/beepboop', false, done ); // $ExpectError - open( '/path/to/beepboop', true, done ); // $ExpectError - open( '/path/to/beepboop', null, done ); // $ExpectError - open( '/path/to/beepboop', undefined, done ); // $ExpectError - open( '/path/to/beepboop', [], done ); // $ExpectError - open( '/path/to/beepboop', {}, done ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` argument which is not a number... -{ - open( '/path/to/beepboop', 'r+', 'abc', done ); // $ExpectError - open( '/path/to/beepboop', 'r+', false, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', true, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', null, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', undefined, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', [], done ); // $ExpectError - open( '/path/to/beepboop', 'r+', {}, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - open(); // $ExpectError - open( 'C:\\foo\\bar\\baz' ); // $ExpectError -} - -// Attached to main export is a `sync` method which returns a number or an error... -{ - open.sync( '/path/to/beepboop' ); // $ExpectType number | Error -} - -// The compiler throws an error if the `sync` method is provided a first argument which is not a string... -{ - open.sync( 123 ); // $ExpectError - open.sync( false ); // $ExpectError - open.sync( true ); // $ExpectError - open.sync( null ); // $ExpectError - open.sync( undefined ); // $ExpectError - open.sync( [] ); // $ExpectError - open.sync( {} ); // $ExpectError - open.sync( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a second argument which is not a string or number... -{ - open.sync( '/path/to/beepboop', false ); // $ExpectError - open.sync( '/path/to/beepboop', true ); // $ExpectError - open.sync( '/path/to/beepboop', null ); // $ExpectError - open.sync( '/path/to/beepboop', [] ); // $ExpectError - open.sync( '/path/to/beepboop', {} ); // $ExpectError - open.sync( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a third argument which is not a number... -{ - open.sync( '/path/to/beepboop', 'r+', false ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', true ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', null ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', [] ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', {} ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided an unsupported number of arguments... -{ - open.sync(); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 71359fe..0000000 --- a/examples/index.js +++ /dev/null @@ -1,56 +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. -*/ - -'use strict'; - -var closeSync = require( '@stdlib/fs-close' ).sync; -var isError = require( '@stdlib/assert-is-error' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - -/* Sync */ - -var fd = open.sync( __filename, 'r+' ); -// returns - -console.log( isError( fd ) ); -// => false - -closeSync( fd ); - -fd = open.sync( 'beepboop' ); -// returns - -console.log( isError( fd ) ); -// => true - -/* Async */ - -open( __filename, onOpen ); -open( 'beepboop', onOpen ); - -function onOpen( error, fd ) { - if ( error ) { - if ( error.code === 'ENOENT' ) { - console.error( 'File does not exist.' ); - } else { - throw error; - } - } else { - closeSync( fd ); - } -} 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..bdb76ee --- /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/utils-define-nonenumerable-read-only-property@esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){if(this instanceof e){var n=[null];n.push.apply(n,arguments);var r=Function.bind.apply(t,n);return new r}return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}var n=t(Object.freeze({__proto__:null,default:{}})),r="r",o=438,u=n.open;function i(e,t,n,i){var a=arguments.length;return 2===a?u(e,r,o,t):3===a?u(e,t,o,n):void u(e,t,n,i)}var a=n.openSync;function p(e,t,n){var u,i;u=arguments.length;try{i=1===u?a(e,r,o):a(e,t,2===u?o:n)}catch(e){return e}return i}e(i,"sync",p);export{i as default,p as sync}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..e41289c --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;0pBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAIzB,CAFC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index cb174b7..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "flags": "r", - "mode": 438 -} diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 8edd6de..0000000 --- a/lib/index.js +++ /dev/null @@ -1,63 +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. -*/ - -'use strict'; - -/** -* Open a file. -* -* @module @stdlib/fs-open -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var openSync = require( '@stdlib/fs-open' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var sync = require( './sync.js' ); - - -// MAIN // - -setReadOnly( main, 'sync', sync ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index feb5171..0000000 --- a/lib/main.js +++ /dev/null @@ -1,64 +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. -*/ - -'use strict'; - -// MODULES // - -var op = require( 'fs' ).open; -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Asynchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @param {Function} clbk - callback to invoke after opening a file -* @returns {void} -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -*/ -function open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare - var nargs = arguments.length; - if ( nargs === 2 ) { - return op( path, defaults.flags, defaults.mode, flags ); - } - if ( nargs === 3 ) { - return op( path, flags, defaults.mode, mode ); - } - op( path, flags, mode, clbk ); -} - - -// EXPORTS // - -module.exports = open; diff --git a/lib/sync.js b/lib/sync.js deleted file mode 100644 index d8d2e00..0000000 --- a/lib/sync.js +++ /dev/null @@ -1,68 +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. -*/ - -'use strict'; - -// MODULES // - -var open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Synchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @returns {(integer|Error)} file descriptor or an error -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -function openSync( path, flags, mode ) { - var nargs; - var fd; - - nargs = arguments.length; - try { - if ( nargs === 1 ) { - fd = open( path, defaults.flags, defaults.mode ); - } else if ( nargs === 2 ) { - fd = open( path, flags, defaults.mode ); - } else { - fd = open( path, flags, mode ); - } - } catch ( err ) { - return err; - } - return fd; -} - - -// EXPORTS // - -module.exports = openSync; diff --git a/package.json b/package.json index 94dff5d..20ba9d3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Open a file.", "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/utils-define-nonenumerable-read-only-property": "^0.0.7", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.0.8", - "@stdlib/assert-is-error": "^0.0.8", - "@stdlib/assert-is-nonnegative-integer": "^0.0.7", - "@stdlib/bench": "^0.0.12", - "@stdlib/fs-close": "^0.0.7", - "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", "stdfs", @@ -82,4 +30,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..19f3924 --- /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 7d5a851..0000000 --- a/test/test.js +++ /dev/null @@ -1,38 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is a function to open a file synchronously', function test( t ) { - t.equal( typeof open.sync, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index b58a6e1..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,110 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/main.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - open( __filename, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - open( __filename, 'r+', onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - open( __filename, 'r+', 438, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - open( 'beepboopbapbop', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', 438, onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); diff --git a/test/test.sync.js b/test/test.sync.js deleted file mode 100644 index 5132589..0000000 --- a/test/test.sync.js +++ /dev/null @@ -1,83 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/sync.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - var fd = open( __filename ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - var fd = open( __filename, 'r+' ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - var fd = open( __filename, 'r+', 438 ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - var fd = open( 'beepboopbapbop' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+', 438 ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); From dbad527d3c45fec93456e948f9f2498228e8f588 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Jun 2023 01:04:42 +0000 Subject: [PATCH 023/113] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ba6867a..94dff5d 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.0.8", @@ -81,4 +82,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From cc5c9044994fbd9f088be8d8731070f9074dbe5f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Jun 2023 02:11:46 +0000 Subject: [PATCH 024/113] Remove files --- index.d.ts | 150 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6332 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 c6e863c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,150 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Buffer } from 'buffer'; - -/** -* Callback invoked after opening a file. -* -* @param err - error argument -* @param fd - file descriptor -*/ -type Callback = ( err: Error, fd: number ) => void; - -/** -* Interface for opening a file. -*/ -interface Open { - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', 438, onOpen ); - */ - ( path: string | Buffer, flags: string | number, mode: number, clbk: Callback ): void; // tslint-disable-line max-line-length - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', onOpen ); - */ - ( path: string | Buffer, flags: string | number, clbk: Callback ): void; - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, onOpen ); - */ - ( path: string | Buffer, clbk: Callback ): void; - - /** - * Synchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @returns file descriptor or an error - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * var fd = open.sync( __filename, 'r+' ); - * if ( fd instanceof Error ) { - * throw fd; - * } - * closeSync( fd ); - */ - sync( path: string | Buffer, flags?: string | number, mode?: number ): number | Error; // tslint-disable-line max-line-length -} - -/** -* Asynchronously opens a file. -* -* @param path - file path -* @param flags - file system flags (default: 'r') -* @param mode - file mode (default: 0o666) -* @param clbk - callback to invoke after opening a file -* -* @example -* var closeSync = require( `@stdlib/fs/close` ).sync; -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( `@stdlib/fs/close` ).sync; -* -* var fd = open.sync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -declare var open: Open; - - -// EXPORTS // - -export = open; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index bdb76ee..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/utils-define-nonenumerable-read-only-property@esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){if(this instanceof e){var n=[null];n.push.apply(n,arguments);var r=Function.bind.apply(t,n);return new r}return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}var n=t(Object.freeze({__proto__:null,default:{}})),r="r",o=438,u=n.open;function i(e,t,n,i){var a=arguments.length;return 2===a?u(e,r,o,t):3===a?u(e,t,o,n):void u(e,t,n,i)}var a=n.openSync;function p(e,t,n){var u,i;u=arguments.length;try{i=1===u?a(e,r,o):a(e,t,2===u?o:n)}catch(e){return e}return i}e(i,"sync",p);export{i as default,p as sync}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index e41289c..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;0pBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAIzB,CAFC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 19f3924..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 3d14cb7ee03def703bf5cf5d8c7b8ba228d9208f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Jun 2023 02:12:27 +0000 Subject: [PATCH 025/113] 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 | 53 +- benchmark/benchmark.js | 77 - branches.md | 53 - docs/repl.txt | 65 - docs/types/test.ts | 129 - examples/index.js | 56 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/defaults.json | 4 - lib/index.js | 63 - lib/main.js | 64 - lib/sync.js | 68 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 38 - test/test.main.js | 110 - test/test.sync.js | 83 - 41 files changed, 6211 insertions(+), 3974 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/defaults.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/sync.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.sync.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 8b7861a..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-06-01T00:53:17.616Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index a3a4470..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/fs/open) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 5eb1ff1..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/fs/open) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 3201e5c..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: '14 2 * * 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 + + ```
@@ -212,7 +211,7 @@ function onOpen( error, fd ) { ## 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]. @@ -276,11 +275,11 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close +[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close/tree/esm -[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists +[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists/tree/esm -[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file +[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 567aec3..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,77 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var closeSync = require( '@stdlib/fs-close' ).sync; -var pkg = require( './../package.json' ).name; -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return open( __filename, 'r+', done ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function done( error, fd ) { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - if ( error ) { - b.fail( error.message ); - } - next(); - } -}); - -bench( pkg+':sync', function benchmark( b ) { - var fd; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - fd = open.sync( __filename, 'r+' ); - if ( fd instanceof Error ) { - b.fail( fd.message ); - } else { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - } - } - b.toc(); - if ( fd instanceof Error ) { - b.fail( 'something went wrong' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index fa29fdf..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/fs/open" -%% click B href "https://github.com/stdlib-js/fs-open/tree/main" -%% click C href "https://github.com/stdlib-js/fs-open/tree/production" -%% click D href "https://github.com/stdlib-js/fs-open/tree/esm" -%% click E href "https://github.com/stdlib-js/fs-open/tree/deno" -%% click F href "https://github.com/stdlib-js/fs-open/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/fs/open -[production-url]: https://github.com/stdlib-js/fs-open/tree/production -[deno-url]: https://github.com/stdlib-js/fs-open/tree/deno -[umd-url]: https://github.com/stdlib-js/fs-open/tree/umd -[esm-url]: https://github.com/stdlib-js/fs-open/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4cbf7ac..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,65 +0,0 @@ - -{{alias}}( path[, flags[, mode]], clbk ) - Asynchronously opens a file. - - Some characters, such as <>:"/\|?*, are reserved under Windows. - Under NTFS, if the path contains a colon, Node.js will open a file system - stream. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - clbk: Function - Callback to invoke upon opening a file. - - Examples - -------- - > function onOpen( error, fd ) { - ... if ( error ) { - ... console.error( error.message ); - ... } else { - ... {{alias:@stdlib/fs/close}}.sync( fd ); - ... } - ... }; - > {{alias}}( './beep/boop.txt', onOpen ); - - -{{alias}}.sync( path[, flags[, mode]] ) - Synchronously opens a file. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - Returns - ------- - fd: Error|integer - File descriptor. - - Examples - -------- - > var fd = {{alias}}.sync( './beep/boop.txt' ); - > if ( !{{alias:@stdlib/assert/is-error}}( fd ) ) { {{alias:@stdlib/fs/close}}.sync( fd ); }; - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 67907a2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,129 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 open = require( './index' ); - -const done = ( error: Error, fd: number ) => { - if ( error || !fd ) { - throw error; - } -}; - - -// TESTS // - -// The function does not have a return value... -{ - open( '/path/to/beepboop', done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a string... -{ - open( 123, done ); // $ExpectError - open( false, done ); // $ExpectError - open( true, done ); // $ExpectError - open( null, done ); // $ExpectError - open( undefined, done ); // $ExpectError - open( [], done ); // $ExpectError - open( {}, done ); // $ExpectError - open( ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a last argument which is not a function with the expected signature... -{ - open( '/path/to/beepboop', 'abc' ); // $ExpectError - open( '/path/to/beepboop', 123 ); // $ExpectError - open( '/path/to/beepboop', false ); // $ExpectError - open( '/path/to/beepboop', true ); // $ExpectError - open( '/path/to/beepboop', null ); // $ExpectError - open( '/path/to/beepboop', undefined ); // $ExpectError - open( '/path/to/beepboop', [] ); // $ExpectError - open( '/path/to/beepboop', {} ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `flags` argument which is not a string or number... -{ - open( '/path/to/beepboop', false, done ); // $ExpectError - open( '/path/to/beepboop', true, done ); // $ExpectError - open( '/path/to/beepboop', null, done ); // $ExpectError - open( '/path/to/beepboop', undefined, done ); // $ExpectError - open( '/path/to/beepboop', [], done ); // $ExpectError - open( '/path/to/beepboop', {}, done ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` argument which is not a number... -{ - open( '/path/to/beepboop', 'r+', 'abc', done ); // $ExpectError - open( '/path/to/beepboop', 'r+', false, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', true, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', null, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', undefined, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', [], done ); // $ExpectError - open( '/path/to/beepboop', 'r+', {}, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - open(); // $ExpectError - open( 'C:\\foo\\bar\\baz' ); // $ExpectError -} - -// Attached to main export is a `sync` method which returns a number or an error... -{ - open.sync( '/path/to/beepboop' ); // $ExpectType number | Error -} - -// The compiler throws an error if the `sync` method is provided a first argument which is not a string... -{ - open.sync( 123 ); // $ExpectError - open.sync( false ); // $ExpectError - open.sync( true ); // $ExpectError - open.sync( null ); // $ExpectError - open.sync( undefined ); // $ExpectError - open.sync( [] ); // $ExpectError - open.sync( {} ); // $ExpectError - open.sync( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a second argument which is not a string or number... -{ - open.sync( '/path/to/beepboop', false ); // $ExpectError - open.sync( '/path/to/beepboop', true ); // $ExpectError - open.sync( '/path/to/beepboop', null ); // $ExpectError - open.sync( '/path/to/beepboop', [] ); // $ExpectError - open.sync( '/path/to/beepboop', {} ); // $ExpectError - open.sync( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a third argument which is not a number... -{ - open.sync( '/path/to/beepboop', 'r+', false ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', true ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', null ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', [] ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', {} ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided an unsupported number of arguments... -{ - open.sync(); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 71359fe..0000000 --- a/examples/index.js +++ /dev/null @@ -1,56 +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. -*/ - -'use strict'; - -var closeSync = require( '@stdlib/fs-close' ).sync; -var isError = require( '@stdlib/assert-is-error' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - -/* Sync */ - -var fd = open.sync( __filename, 'r+' ); -// returns - -console.log( isError( fd ) ); -// => false - -closeSync( fd ); - -fd = open.sync( 'beepboop' ); -// returns - -console.log( isError( fd ) ); -// => true - -/* Async */ - -open( __filename, onOpen ); -open( 'beepboop', onOpen ); - -function onOpen( error, fd ) { - if ( error ) { - if ( error.code === 'ENOENT' ) { - console.error( 'File does not exist.' ); - } else { - throw error; - } - } else { - closeSync( fd ); - } -} 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..bdb76ee --- /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/utils-define-nonenumerable-read-only-property@esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){if(this instanceof e){var n=[null];n.push.apply(n,arguments);var r=Function.bind.apply(t,n);return new r}return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}var n=t(Object.freeze({__proto__:null,default:{}})),r="r",o=438,u=n.open;function i(e,t,n,i){var a=arguments.length;return 2===a?u(e,r,o,t):3===a?u(e,t,o,n):void u(e,t,n,i)}var a=n.openSync;function p(e,t,n){var u,i;u=arguments.length;try{i=1===u?a(e,r,o):a(e,t,2===u?o:n)}catch(e){return e}return i}e(i,"sync",p);export{i as default,p as sync}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..e41289c --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;0pBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAIzB,CAFC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index cb174b7..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "flags": "r", - "mode": 438 -} diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 8edd6de..0000000 --- a/lib/index.js +++ /dev/null @@ -1,63 +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. -*/ - -'use strict'; - -/** -* Open a file. -* -* @module @stdlib/fs-open -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var openSync = require( '@stdlib/fs-open' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var sync = require( './sync.js' ); - - -// MAIN // - -setReadOnly( main, 'sync', sync ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index feb5171..0000000 --- a/lib/main.js +++ /dev/null @@ -1,64 +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. -*/ - -'use strict'; - -// MODULES // - -var op = require( 'fs' ).open; -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Asynchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @param {Function} clbk - callback to invoke after opening a file -* @returns {void} -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -*/ -function open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare - var nargs = arguments.length; - if ( nargs === 2 ) { - return op( path, defaults.flags, defaults.mode, flags ); - } - if ( nargs === 3 ) { - return op( path, flags, defaults.mode, mode ); - } - op( path, flags, mode, clbk ); -} - - -// EXPORTS // - -module.exports = open; diff --git a/lib/sync.js b/lib/sync.js deleted file mode 100644 index d8d2e00..0000000 --- a/lib/sync.js +++ /dev/null @@ -1,68 +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. -*/ - -'use strict'; - -// MODULES // - -var open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Synchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @returns {(integer|Error)} file descriptor or an error -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -function openSync( path, flags, mode ) { - var nargs; - var fd; - - nargs = arguments.length; - try { - if ( nargs === 1 ) { - fd = open( path, defaults.flags, defaults.mode ); - } else if ( nargs === 2 ) { - fd = open( path, flags, defaults.mode ); - } else { - fd = open( path, flags, mode ); - } - } catch ( err ) { - return err; - } - return fd; -} - - -// EXPORTS // - -module.exports = openSync; diff --git a/package.json b/package.json index 94dff5d..20ba9d3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Open a file.", "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/utils-define-nonenumerable-read-only-property": "^0.0.7", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.0.8", - "@stdlib/assert-is-error": "^0.0.8", - "@stdlib/assert-is-nonnegative-integer": "^0.0.7", - "@stdlib/bench": "^0.0.12", - "@stdlib/fs-close": "^0.0.7", - "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", "stdfs", @@ -82,4 +30,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..3a1652b --- /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 7d5a851..0000000 --- a/test/test.js +++ /dev/null @@ -1,38 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is a function to open a file synchronously', function test( t ) { - t.equal( typeof open.sync, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index b58a6e1..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,110 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/main.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - open( __filename, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - open( __filename, 'r+', onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - open( __filename, 'r+', 438, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - open( 'beepboopbapbop', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', 438, onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); diff --git a/test/test.sync.js b/test/test.sync.js deleted file mode 100644 index 5132589..0000000 --- a/test/test.sync.js +++ /dev/null @@ -1,83 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/sync.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - var fd = open( __filename ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - var fd = open( __filename, 'r+' ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - var fd = open( __filename, 'r+', 438 ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - var fd = open( 'beepboopbapbop' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+', 438 ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); From 6eecf2821fbba0e2e68336caa7c2c8c88fc45ef0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jul 2023 01:03:01 +0000 Subject: [PATCH 026/113] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ba6867a..94dff5d 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.0.8", @@ -81,4 +82,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 88f5268b5b5342ff393e5a67c0b05d694cfd90e6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jul 2023 02:07:00 +0000 Subject: [PATCH 027/113] Remove files --- index.d.ts | 150 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6332 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 c6e863c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,150 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Buffer } from 'buffer'; - -/** -* Callback invoked after opening a file. -* -* @param err - error argument -* @param fd - file descriptor -*/ -type Callback = ( err: Error, fd: number ) => void; - -/** -* Interface for opening a file. -*/ -interface Open { - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', 438, onOpen ); - */ - ( path: string | Buffer, flags: string | number, mode: number, clbk: Callback ): void; // tslint-disable-line max-line-length - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', onOpen ); - */ - ( path: string | Buffer, flags: string | number, clbk: Callback ): void; - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, onOpen ); - */ - ( path: string | Buffer, clbk: Callback ): void; - - /** - * Synchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @returns file descriptor or an error - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * var fd = open.sync( __filename, 'r+' ); - * if ( fd instanceof Error ) { - * throw fd; - * } - * closeSync( fd ); - */ - sync( path: string | Buffer, flags?: string | number, mode?: number ): number | Error; // tslint-disable-line max-line-length -} - -/** -* Asynchronously opens a file. -* -* @param path - file path -* @param flags - file system flags (default: 'r') -* @param mode - file mode (default: 0o666) -* @param clbk - callback to invoke after opening a file -* -* @example -* var closeSync = require( `@stdlib/fs/close` ).sync; -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( `@stdlib/fs/close` ).sync; -* -* var fd = open.sync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -declare var open: Open; - - -// EXPORTS // - -export = open; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index bdb76ee..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/utils-define-nonenumerable-read-only-property@esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){if(this instanceof e){var n=[null];n.push.apply(n,arguments);var r=Function.bind.apply(t,n);return new r}return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}var n=t(Object.freeze({__proto__:null,default:{}})),r="r",o=438,u=n.open;function i(e,t,n,i){var a=arguments.length;return 2===a?u(e,r,o,t):3===a?u(e,t,o,n):void u(e,t,n,i)}var a=n.openSync;function p(e,t,n){var u,i;u=arguments.length;try{i=1===u?a(e,r,o):a(e,t,2===u?o:n)}catch(e){return e}return i}e(i,"sync",p);export{i as default,p as sync}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index e41289c..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;0pBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAIzB,CAFC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 3a1652b..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 7e1523b523a7b8b03fc8c5165646bb2a83758671 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jul 2023 02:07:40 +0000 Subject: [PATCH 028/113] 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 | 53 +- benchmark/benchmark.js | 77 - branches.md | 53 - docs/repl.txt | 65 - docs/types/test.ts | 129 - examples/index.js | 56 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/defaults.json | 4 - lib/index.js | 63 - lib/main.js | 64 - lib/sync.js | 68 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 38 - test/test.main.js | 110 - test/test.sync.js | 83 - 41 files changed, 6211 insertions(+), 3974 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/defaults.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/sync.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.sync.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 0d6cac9..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-07-01T00:51:49.288Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index a3a4470..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/fs/open) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 5eb1ff1..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/fs/open) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 3201e5c..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: '14 2 * * 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 + + ```
@@ -212,7 +211,7 @@ function onOpen( error, fd ) { ## 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]. @@ -276,11 +275,11 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close +[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close/tree/esm -[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists +[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists/tree/esm -[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file +[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 567aec3..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,77 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var closeSync = require( '@stdlib/fs-close' ).sync; -var pkg = require( './../package.json' ).name; -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return open( __filename, 'r+', done ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function done( error, fd ) { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - if ( error ) { - b.fail( error.message ); - } - next(); - } -}); - -bench( pkg+':sync', function benchmark( b ) { - var fd; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - fd = open.sync( __filename, 'r+' ); - if ( fd instanceof Error ) { - b.fail( fd.message ); - } else { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - } - } - b.toc(); - if ( fd instanceof Error ) { - b.fail( 'something went wrong' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index fa29fdf..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/fs/open" -%% click B href "https://github.com/stdlib-js/fs-open/tree/main" -%% click C href "https://github.com/stdlib-js/fs-open/tree/production" -%% click D href "https://github.com/stdlib-js/fs-open/tree/esm" -%% click E href "https://github.com/stdlib-js/fs-open/tree/deno" -%% click F href "https://github.com/stdlib-js/fs-open/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/fs/open -[production-url]: https://github.com/stdlib-js/fs-open/tree/production -[deno-url]: https://github.com/stdlib-js/fs-open/tree/deno -[umd-url]: https://github.com/stdlib-js/fs-open/tree/umd -[esm-url]: https://github.com/stdlib-js/fs-open/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4cbf7ac..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,65 +0,0 @@ - -{{alias}}( path[, flags[, mode]], clbk ) - Asynchronously opens a file. - - Some characters, such as <>:"/\|?*, are reserved under Windows. - Under NTFS, if the path contains a colon, Node.js will open a file system - stream. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - clbk: Function - Callback to invoke upon opening a file. - - Examples - -------- - > function onOpen( error, fd ) { - ... if ( error ) { - ... console.error( error.message ); - ... } else { - ... {{alias:@stdlib/fs/close}}.sync( fd ); - ... } - ... }; - > {{alias}}( './beep/boop.txt', onOpen ); - - -{{alias}}.sync( path[, flags[, mode]] ) - Synchronously opens a file. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - Returns - ------- - fd: Error|integer - File descriptor. - - Examples - -------- - > var fd = {{alias}}.sync( './beep/boop.txt' ); - > if ( !{{alias:@stdlib/assert/is-error}}( fd ) ) { {{alias:@stdlib/fs/close}}.sync( fd ); }; - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 67907a2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,129 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 open = require( './index' ); - -const done = ( error: Error, fd: number ) => { - if ( error || !fd ) { - throw error; - } -}; - - -// TESTS // - -// The function does not have a return value... -{ - open( '/path/to/beepboop', done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a string... -{ - open( 123, done ); // $ExpectError - open( false, done ); // $ExpectError - open( true, done ); // $ExpectError - open( null, done ); // $ExpectError - open( undefined, done ); // $ExpectError - open( [], done ); // $ExpectError - open( {}, done ); // $ExpectError - open( ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a last argument which is not a function with the expected signature... -{ - open( '/path/to/beepboop', 'abc' ); // $ExpectError - open( '/path/to/beepboop', 123 ); // $ExpectError - open( '/path/to/beepboop', false ); // $ExpectError - open( '/path/to/beepboop', true ); // $ExpectError - open( '/path/to/beepboop', null ); // $ExpectError - open( '/path/to/beepboop', undefined ); // $ExpectError - open( '/path/to/beepboop', [] ); // $ExpectError - open( '/path/to/beepboop', {} ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `flags` argument which is not a string or number... -{ - open( '/path/to/beepboop', false, done ); // $ExpectError - open( '/path/to/beepboop', true, done ); // $ExpectError - open( '/path/to/beepboop', null, done ); // $ExpectError - open( '/path/to/beepboop', undefined, done ); // $ExpectError - open( '/path/to/beepboop', [], done ); // $ExpectError - open( '/path/to/beepboop', {}, done ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` argument which is not a number... -{ - open( '/path/to/beepboop', 'r+', 'abc', done ); // $ExpectError - open( '/path/to/beepboop', 'r+', false, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', true, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', null, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', undefined, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', [], done ); // $ExpectError - open( '/path/to/beepboop', 'r+', {}, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - open(); // $ExpectError - open( 'C:\\foo\\bar\\baz' ); // $ExpectError -} - -// Attached to main export is a `sync` method which returns a number or an error... -{ - open.sync( '/path/to/beepboop' ); // $ExpectType number | Error -} - -// The compiler throws an error if the `sync` method is provided a first argument which is not a string... -{ - open.sync( 123 ); // $ExpectError - open.sync( false ); // $ExpectError - open.sync( true ); // $ExpectError - open.sync( null ); // $ExpectError - open.sync( undefined ); // $ExpectError - open.sync( [] ); // $ExpectError - open.sync( {} ); // $ExpectError - open.sync( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a second argument which is not a string or number... -{ - open.sync( '/path/to/beepboop', false ); // $ExpectError - open.sync( '/path/to/beepboop', true ); // $ExpectError - open.sync( '/path/to/beepboop', null ); // $ExpectError - open.sync( '/path/to/beepboop', [] ); // $ExpectError - open.sync( '/path/to/beepboop', {} ); // $ExpectError - open.sync( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a third argument which is not a number... -{ - open.sync( '/path/to/beepboop', 'r+', false ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', true ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', null ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', [] ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', {} ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided an unsupported number of arguments... -{ - open.sync(); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 71359fe..0000000 --- a/examples/index.js +++ /dev/null @@ -1,56 +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. -*/ - -'use strict'; - -var closeSync = require( '@stdlib/fs-close' ).sync; -var isError = require( '@stdlib/assert-is-error' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - -/* Sync */ - -var fd = open.sync( __filename, 'r+' ); -// returns - -console.log( isError( fd ) ); -// => false - -closeSync( fd ); - -fd = open.sync( 'beepboop' ); -// returns - -console.log( isError( fd ) ); -// => true - -/* Async */ - -open( __filename, onOpen ); -open( 'beepboop', onOpen ); - -function onOpen( error, fd ) { - if ( error ) { - if ( error.code === 'ENOENT' ) { - console.error( 'File does not exist.' ); - } else { - throw error; - } - } else { - closeSync( fd ); - } -} 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..bdb76ee --- /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/utils-define-nonenumerable-read-only-property@esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){if(this instanceof e){var n=[null];n.push.apply(n,arguments);var r=Function.bind.apply(t,n);return new r}return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}var n=t(Object.freeze({__proto__:null,default:{}})),r="r",o=438,u=n.open;function i(e,t,n,i){var a=arguments.length;return 2===a?u(e,r,o,t):3===a?u(e,t,o,n):void u(e,t,n,i)}var a=n.openSync;function p(e,t,n){var u,i;u=arguments.length;try{i=1===u?a(e,r,o):a(e,t,2===u?o:n)}catch(e){return e}return i}e(i,"sync",p);export{i as default,p as sync}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..e41289c --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;0pBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAIzB,CAFC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index cb174b7..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "flags": "r", - "mode": 438 -} diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 8edd6de..0000000 --- a/lib/index.js +++ /dev/null @@ -1,63 +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. -*/ - -'use strict'; - -/** -* Open a file. -* -* @module @stdlib/fs-open -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var openSync = require( '@stdlib/fs-open' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var sync = require( './sync.js' ); - - -// MAIN // - -setReadOnly( main, 'sync', sync ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index feb5171..0000000 --- a/lib/main.js +++ /dev/null @@ -1,64 +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. -*/ - -'use strict'; - -// MODULES // - -var op = require( 'fs' ).open; -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Asynchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @param {Function} clbk - callback to invoke after opening a file -* @returns {void} -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -*/ -function open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare - var nargs = arguments.length; - if ( nargs === 2 ) { - return op( path, defaults.flags, defaults.mode, flags ); - } - if ( nargs === 3 ) { - return op( path, flags, defaults.mode, mode ); - } - op( path, flags, mode, clbk ); -} - - -// EXPORTS // - -module.exports = open; diff --git a/lib/sync.js b/lib/sync.js deleted file mode 100644 index d8d2e00..0000000 --- a/lib/sync.js +++ /dev/null @@ -1,68 +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. -*/ - -'use strict'; - -// MODULES // - -var open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Synchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @returns {(integer|Error)} file descriptor or an error -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -function openSync( path, flags, mode ) { - var nargs; - var fd; - - nargs = arguments.length; - try { - if ( nargs === 1 ) { - fd = open( path, defaults.flags, defaults.mode ); - } else if ( nargs === 2 ) { - fd = open( path, flags, defaults.mode ); - } else { - fd = open( path, flags, mode ); - } - } catch ( err ) { - return err; - } - return fd; -} - - -// EXPORTS // - -module.exports = openSync; diff --git a/package.json b/package.json index 94dff5d..20ba9d3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Open a file.", "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/utils-define-nonenumerable-read-only-property": "^0.0.7", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.0.8", - "@stdlib/assert-is-error": "^0.0.8", - "@stdlib/assert-is-nonnegative-integer": "^0.0.7", - "@stdlib/bench": "^0.0.12", - "@stdlib/fs-close": "^0.0.7", - "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", "stdfs", @@ -82,4 +30,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..406df08 --- /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 7d5a851..0000000 --- a/test/test.js +++ /dev/null @@ -1,38 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is a function to open a file synchronously', function test( t ) { - t.equal( typeof open.sync, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index b58a6e1..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,110 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/main.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - open( __filename, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - open( __filename, 'r+', onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - open( __filename, 'r+', 438, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - open( 'beepboopbapbop', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', 438, onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); diff --git a/test/test.sync.js b/test/test.sync.js deleted file mode 100644 index 5132589..0000000 --- a/test/test.sync.js +++ /dev/null @@ -1,83 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/sync.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.equal( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - var fd = open( __filename ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - var fd = open( __filename, 'r+' ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - var fd = open( __filename, 'r+', 438 ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - var fd = open( 'beepboopbapbop' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+', 438 ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); From 282fcf3d156112190004a0401e4e2a52f62b2686 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Aug 2023 01:01:22 +0000 Subject: [PATCH 029/113] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ba6867a..94dff5d 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.0.8", @@ -81,4 +82,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 54836c6fb59d601b226a7ce94ba8cdf0862bb4aa Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Aug 2023 02:06:13 +0000 Subject: [PATCH 030/113] Remove files --- index.d.ts | 150 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6332 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 c6e863c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,150 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Buffer } from 'buffer'; - -/** -* Callback invoked after opening a file. -* -* @param err - error argument -* @param fd - file descriptor -*/ -type Callback = ( err: Error, fd: number ) => void; - -/** -* Interface for opening a file. -*/ -interface Open { - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', 438, onOpen ); - */ - ( path: string | Buffer, flags: string | number, mode: number, clbk: Callback ): void; // tslint-disable-line max-line-length - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', onOpen ); - */ - ( path: string | Buffer, flags: string | number, clbk: Callback ): void; - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, onOpen ); - */ - ( path: string | Buffer, clbk: Callback ): void; - - /** - * Synchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @returns file descriptor or an error - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * var fd = open.sync( __filename, 'r+' ); - * if ( fd instanceof Error ) { - * throw fd; - * } - * closeSync( fd ); - */ - sync( path: string | Buffer, flags?: string | number, mode?: number ): number | Error; // tslint-disable-line max-line-length -} - -/** -* Asynchronously opens a file. -* -* @param path - file path -* @param flags - file system flags (default: 'r') -* @param mode - file mode (default: 0o666) -* @param clbk - callback to invoke after opening a file -* -* @example -* var closeSync = require( `@stdlib/fs/close` ).sync; -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( `@stdlib/fs/close` ).sync; -* -* var fd = open.sync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -declare var open: Open; - - -// EXPORTS // - -export = open; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index bdb76ee..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/utils-define-nonenumerable-read-only-property@esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){if(this instanceof e){var n=[null];n.push.apply(n,arguments);var r=Function.bind.apply(t,n);return new r}return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}var n=t(Object.freeze({__proto__:null,default:{}})),r="r",o=438,u=n.open;function i(e,t,n,i){var a=arguments.length;return 2===a?u(e,r,o,t):3===a?u(e,t,o,n):void u(e,t,n,i)}var a=n.openSync;function p(e,t,n){var u,i;u=arguments.length;try{i=1===u?a(e,r,o):a(e,t,2===u?o:n)}catch(e){return e}return i}e(i,"sync",p);export{i as default,p as sync}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index e41289c..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;0pBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAIzB,CAFC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 406df08..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From f520eae9ce8a9a00f5edfae25fa17548026e0092 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Aug 2023 02:07:08 +0000 Subject: [PATCH 031/113] 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 | 53 +- benchmark/benchmark.js | 77 - branches.md | 53 - docs/repl.txt | 65 - docs/types/test.ts | 129 - examples/index.js | 56 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/defaults.json | 4 - lib/index.js | 63 - lib/main.js | 64 - lib/sync.js | 68 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 38 - test/test.main.js | 110 - test/test.sync.js | 83 - 41 files changed, 6211 insertions(+), 3974 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/defaults.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/sync.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.sync.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 308e123..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-08-01T00:49:07.490Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index a3a4470..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/fs/open) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 5eb1ff1..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/fs/open) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 3201e5c..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: '14 2 * * 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 + + ```
@@ -212,7 +211,7 @@ function onOpen( error, fd ) { ## 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]. @@ -276,11 +275,11 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close +[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close/tree/esm -[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists +[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists/tree/esm -[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file +[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 567aec3..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,77 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var closeSync = require( '@stdlib/fs-close' ).sync; -var pkg = require( './../package.json' ).name; -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return open( __filename, 'r+', done ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function done( error, fd ) { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - if ( error ) { - b.fail( error.message ); - } - next(); - } -}); - -bench( pkg+':sync', function benchmark( b ) { - var fd; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - fd = open.sync( __filename, 'r+' ); - if ( fd instanceof Error ) { - b.fail( fd.message ); - } else { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - } - } - b.toc(); - if ( fd instanceof Error ) { - b.fail( 'something went wrong' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index fa29fdf..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/fs/open" -%% click B href "https://github.com/stdlib-js/fs-open/tree/main" -%% click C href "https://github.com/stdlib-js/fs-open/tree/production" -%% click D href "https://github.com/stdlib-js/fs-open/tree/esm" -%% click E href "https://github.com/stdlib-js/fs-open/tree/deno" -%% click F href "https://github.com/stdlib-js/fs-open/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/fs/open -[production-url]: https://github.com/stdlib-js/fs-open/tree/production -[deno-url]: https://github.com/stdlib-js/fs-open/tree/deno -[umd-url]: https://github.com/stdlib-js/fs-open/tree/umd -[esm-url]: https://github.com/stdlib-js/fs-open/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4cbf7ac..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,65 +0,0 @@ - -{{alias}}( path[, flags[, mode]], clbk ) - Asynchronously opens a file. - - Some characters, such as <>:"/\|?*, are reserved under Windows. - Under NTFS, if the path contains a colon, Node.js will open a file system - stream. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - clbk: Function - Callback to invoke upon opening a file. - - Examples - -------- - > function onOpen( error, fd ) { - ... if ( error ) { - ... console.error( error.message ); - ... } else { - ... {{alias:@stdlib/fs/close}}.sync( fd ); - ... } - ... }; - > {{alias}}( './beep/boop.txt', onOpen ); - - -{{alias}}.sync( path[, flags[, mode]] ) - Synchronously opens a file. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - Returns - ------- - fd: Error|integer - File descriptor. - - Examples - -------- - > var fd = {{alias}}.sync( './beep/boop.txt' ); - > if ( !{{alias:@stdlib/assert/is-error}}( fd ) ) { {{alias:@stdlib/fs/close}}.sync( fd ); }; - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 67907a2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,129 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 open = require( './index' ); - -const done = ( error: Error, fd: number ) => { - if ( error || !fd ) { - throw error; - } -}; - - -// TESTS // - -// The function does not have a return value... -{ - open( '/path/to/beepboop', done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a string... -{ - open( 123, done ); // $ExpectError - open( false, done ); // $ExpectError - open( true, done ); // $ExpectError - open( null, done ); // $ExpectError - open( undefined, done ); // $ExpectError - open( [], done ); // $ExpectError - open( {}, done ); // $ExpectError - open( ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a last argument which is not a function with the expected signature... -{ - open( '/path/to/beepboop', 'abc' ); // $ExpectError - open( '/path/to/beepboop', 123 ); // $ExpectError - open( '/path/to/beepboop', false ); // $ExpectError - open( '/path/to/beepboop', true ); // $ExpectError - open( '/path/to/beepboop', null ); // $ExpectError - open( '/path/to/beepboop', undefined ); // $ExpectError - open( '/path/to/beepboop', [] ); // $ExpectError - open( '/path/to/beepboop', {} ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `flags` argument which is not a string or number... -{ - open( '/path/to/beepboop', false, done ); // $ExpectError - open( '/path/to/beepboop', true, done ); // $ExpectError - open( '/path/to/beepboop', null, done ); // $ExpectError - open( '/path/to/beepboop', undefined, done ); // $ExpectError - open( '/path/to/beepboop', [], done ); // $ExpectError - open( '/path/to/beepboop', {}, done ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` argument which is not a number... -{ - open( '/path/to/beepboop', 'r+', 'abc', done ); // $ExpectError - open( '/path/to/beepboop', 'r+', false, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', true, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', null, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', undefined, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', [], done ); // $ExpectError - open( '/path/to/beepboop', 'r+', {}, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - open(); // $ExpectError - open( 'C:\\foo\\bar\\baz' ); // $ExpectError -} - -// Attached to main export is a `sync` method which returns a number or an error... -{ - open.sync( '/path/to/beepboop' ); // $ExpectType number | Error -} - -// The compiler throws an error if the `sync` method is provided a first argument which is not a string... -{ - open.sync( 123 ); // $ExpectError - open.sync( false ); // $ExpectError - open.sync( true ); // $ExpectError - open.sync( null ); // $ExpectError - open.sync( undefined ); // $ExpectError - open.sync( [] ); // $ExpectError - open.sync( {} ); // $ExpectError - open.sync( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a second argument which is not a string or number... -{ - open.sync( '/path/to/beepboop', false ); // $ExpectError - open.sync( '/path/to/beepboop', true ); // $ExpectError - open.sync( '/path/to/beepboop', null ); // $ExpectError - open.sync( '/path/to/beepboop', [] ); // $ExpectError - open.sync( '/path/to/beepboop', {} ); // $ExpectError - open.sync( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a third argument which is not a number... -{ - open.sync( '/path/to/beepboop', 'r+', false ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', true ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', null ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', [] ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', {} ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided an unsupported number of arguments... -{ - open.sync(); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 71359fe..0000000 --- a/examples/index.js +++ /dev/null @@ -1,56 +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. -*/ - -'use strict'; - -var closeSync = require( '@stdlib/fs-close' ).sync; -var isError = require( '@stdlib/assert-is-error' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - -/* Sync */ - -var fd = open.sync( __filename, 'r+' ); -// returns - -console.log( isError( fd ) ); -// => false - -closeSync( fd ); - -fd = open.sync( 'beepboop' ); -// returns - -console.log( isError( fd ) ); -// => true - -/* Async */ - -open( __filename, onOpen ); -open( 'beepboop', onOpen ); - -function onOpen( error, fd ) { - if ( error ) { - if ( error.code === 'ENOENT' ) { - console.error( 'File does not exist.' ); - } else { - throw error; - } - } else { - closeSync( fd ); - } -} 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..bdb76ee --- /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/utils-define-nonenumerable-read-only-property@esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){if(this instanceof e){var n=[null];n.push.apply(n,arguments);var r=Function.bind.apply(t,n);return new r}return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}var n=t(Object.freeze({__proto__:null,default:{}})),r="r",o=438,u=n.open;function i(e,t,n,i){var a=arguments.length;return 2===a?u(e,r,o,t):3===a?u(e,t,o,n):void u(e,t,n,i)}var a=n.openSync;function p(e,t,n){var u,i;u=arguments.length;try{i=1===u?a(e,r,o):a(e,t,2===u?o:n)}catch(e){return e}return i}e(i,"sync",p);export{i as default,p as sync}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..e41289c --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;0pBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAIzB,CAFC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index cb174b7..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "flags": "r", - "mode": 438 -} diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 8edd6de..0000000 --- a/lib/index.js +++ /dev/null @@ -1,63 +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. -*/ - -'use strict'; - -/** -* Open a file. -* -* @module @stdlib/fs-open -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var openSync = require( '@stdlib/fs-open' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var sync = require( './sync.js' ); - - -// MAIN // - -setReadOnly( main, 'sync', sync ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index feb5171..0000000 --- a/lib/main.js +++ /dev/null @@ -1,64 +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. -*/ - -'use strict'; - -// MODULES // - -var op = require( 'fs' ).open; -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Asynchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @param {Function} clbk - callback to invoke after opening a file -* @returns {void} -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -*/ -function open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare - var nargs = arguments.length; - if ( nargs === 2 ) { - return op( path, defaults.flags, defaults.mode, flags ); - } - if ( nargs === 3 ) { - return op( path, flags, defaults.mode, mode ); - } - op( path, flags, mode, clbk ); -} - - -// EXPORTS // - -module.exports = open; diff --git a/lib/sync.js b/lib/sync.js deleted file mode 100644 index d8d2e00..0000000 --- a/lib/sync.js +++ /dev/null @@ -1,68 +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. -*/ - -'use strict'; - -// MODULES // - -var open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Synchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @returns {(integer|Error)} file descriptor or an error -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -function openSync( path, flags, mode ) { - var nargs; - var fd; - - nargs = arguments.length; - try { - if ( nargs === 1 ) { - fd = open( path, defaults.flags, defaults.mode ); - } else if ( nargs === 2 ) { - fd = open( path, flags, defaults.mode ); - } else { - fd = open( path, flags, mode ); - } - } catch ( err ) { - return err; - } - return fd; -} - - -// EXPORTS // - -module.exports = openSync; diff --git a/package.json b/package.json index 94dff5d..20ba9d3 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.7", "description": "Open a file.", "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/utils-define-nonenumerable-read-only-property": "^0.0.7", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.0.8", - "@stdlib/assert-is-error": "^0.0.8", - "@stdlib/assert-is-nonnegative-integer": "^0.0.7", - "@stdlib/bench": "^0.0.12", - "@stdlib/fs-close": "^0.0.7", - "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", "stdfs", @@ -82,4 +30,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..ec5a661 --- /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 3c47135..0000000 --- a/test/test.js +++ /dev/null @@ -1,38 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is a function to open a file synchronously', function test( t ) { - t.equal( typeof open.sync, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 33b938f..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,110 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/main.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - open( __filename, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - open( __filename, 'r+', onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - open( __filename, 'r+', 438, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - open( 'beepboopbapbop', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', 438, onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); diff --git a/test/test.sync.js b/test/test.sync.js deleted file mode 100644 index 56d7b23..0000000 --- a/test/test.sync.js +++ /dev/null @@ -1,83 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/sync.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - var fd = open( __filename ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - var fd = open( __filename, 'r+' ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - var fd = open( __filename, 'r+', 438 ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - var fd = open( 'beepboopbapbop' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+', 438 ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); From 8286c9349c89645c6176f234b96eb9b4d9ec6778 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 22 Sep 2023 03:51:28 +0000 Subject: [PATCH 032/113] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 159e1f7..8c63011 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.0" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.0" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.0.8", @@ -81,4 +82,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 7abfceee6255029174688cc93a4e95b9770d3714 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 22 Sep 2023 04:43:30 +0000 Subject: [PATCH 033/113] Remove files --- index.d.ts | 150 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6332 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 c6e863c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,150 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// - -import { Buffer } from 'buffer'; - -/** -* Callback invoked after opening a file. -* -* @param err - error argument -* @param fd - file descriptor -*/ -type Callback = ( err: Error, fd: number ) => void; - -/** -* Interface for opening a file. -*/ -interface Open { - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', 438, onOpen ); - */ - ( path: string | Buffer, flags: string | number, mode: number, clbk: Callback ): void; // tslint-disable-line max-line-length - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', onOpen ); - */ - ( path: string | Buffer, flags: string | number, clbk: Callback ): void; - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, onOpen ); - */ - ( path: string | Buffer, clbk: Callback ): void; - - /** - * Synchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @returns file descriptor or an error - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * var fd = open.sync( __filename, 'r+' ); - * if ( fd instanceof Error ) { - * throw fd; - * } - * closeSync( fd ); - */ - sync( path: string | Buffer, flags?: string | number, mode?: number ): number | Error; // tslint-disable-line max-line-length -} - -/** -* Asynchronously opens a file. -* -* @param path - file path -* @param flags - file system flags (default: 'r') -* @param mode - file mode (default: 0o666) -* @param clbk - callback to invoke after opening a file -* -* @example -* var closeSync = require( `@stdlib/fs/close` ).sync; -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( `@stdlib/fs/close` ).sync; -* -* var fd = open.sync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -declare var open: Open; - - -// EXPORTS // - -export = open; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index bdb76ee..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/utils-define-nonenumerable-read-only-property@esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){if(this instanceof e){var n=[null];n.push.apply(n,arguments);var r=Function.bind.apply(t,n);return new r}return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}var n=t(Object.freeze({__proto__:null,default:{}})),r="r",o=438,u=n.open;function i(e,t,n,i){var a=arguments.length;return 2===a?u(e,r,o,t):3===a?u(e,t,o,n):void u(e,t,n,i)}var a=n.openSync;function p(e,t,n){var u,i;u=arguments.length;try{i=1===u?a(e,r,o):a(e,t,2===u?o:n)}catch(e){return e}return i}e(i,"sync",p);export{i as default,p as sync}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index e41289c..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;0pBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAIzB,CAFC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index ec5a661..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From d93b661e467009b86e6a93863c504ccec4003629 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 22 Sep 2023 04:44:20 +0000 Subject: [PATCH 034/113] 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 | 53 +- benchmark/benchmark.js | 77 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 65 - docs/types/test.ts | 129 - examples/index.js | 56 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/defaults.json | 4 - lib/index.js | 63 - lib/main.js | 64 - lib/sync.js | 68 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 38 - test/test.main.js | 110 - test/test.sync.js | 83 - 44 files changed, 6211 insertions(+), 4010 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/defaults.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/sync.js create mode 100644 stats.html delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.sync.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 a3a4470..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/fs/open) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 5eb1ff1..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/fs/open) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 3201e5c..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: '14 2 * * 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 + + ```
@@ -223,7 +222,7 @@ function onOpen( error, fd ) { ## 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]. @@ -287,11 +286,11 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close +[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close/tree/esm -[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists +[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists/tree/esm -[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file +[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 567aec3..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,77 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var closeSync = require( '@stdlib/fs-close' ).sync; -var pkg = require( './../package.json' ).name; -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return open( __filename, 'r+', done ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function done( error, fd ) { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - if ( error ) { - b.fail( error.message ); - } - next(); - } -}); - -bench( pkg+':sync', function benchmark( b ) { - var fd; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - fd = open.sync( __filename, 'r+' ); - if ( fd instanceof Error ) { - b.fail( fd.message ); - } else { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - } - } - b.toc(); - if ( fd instanceof Error ) { - b.fail( 'something went wrong' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index fa29fdf..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/fs/open" -%% click B href "https://github.com/stdlib-js/fs-open/tree/main" -%% click C href "https://github.com/stdlib-js/fs-open/tree/production" -%% click D href "https://github.com/stdlib-js/fs-open/tree/esm" -%% click E href "https://github.com/stdlib-js/fs-open/tree/deno" -%% click F href "https://github.com/stdlib-js/fs-open/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/fs/open -[production-url]: https://github.com/stdlib-js/fs-open/tree/production -[deno-url]: https://github.com/stdlib-js/fs-open/tree/deno -[umd-url]: https://github.com/stdlib-js/fs-open/tree/umd -[esm-url]: https://github.com/stdlib-js/fs-open/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 3e10601..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import open from '../docs/types/index'; -export = open; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 5358415..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var u=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var i=u(function(b,y){y.exports={flags:"r",mode:438}});var d=u(function(j,f){ -var a=require("fs").open,o=i();function p(r,e,t,s){var n=arguments.length;if(n===2)return a(r,o.flags,o.mode,e);if(n===3)return a(r,e,o.mode,t);a(r,e,t,s)}f.exports=p -});var m=u(function(k,l){ -var c=require("fs").openSync,v=i();function x(r,e,t){var s,n;s=arguments.length;try{s===1?n=c(r,v.flags,v.mode):s===2?n=c(r,e,v.mode):n=c(r,e,t)}catch(g){return g}return n}l.exports=x -});var S=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),q=d(),O=m();S(q,"sync",O);module.exports=q; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 65b6278..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/main.js", "../lib/sync.js", "../lib/index.js"], - "sourcesContent": ["{\n\t\"flags\": \"r\",\n\t\"mode\": 438\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var open = require( '@stdlib/fs-open' );\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nmodule.exports = open;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nmodule.exports = openSync;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var open = require( '@stdlib/fs-open' );\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var openSync = require( '@stdlib/fs-open' ).sync;\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar sync = require( './sync.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,CAAAA,EAAA,SACC,MAAS,IACT,KAAQ,GACT,ICHA,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAK,QAAS,IAAK,EAAE,KACrBC,EAAW,IA0Bf,SAASC,EAAMC,EAAMC,EAAOC,EAAMC,EAAO,CACxC,IAAIC,EAAQ,UAAU,OACtB,GAAKA,IAAU,EACd,OAAOP,EAAIG,EAAMF,EAAS,MAAOA,EAAS,KAAMG,CAAM,EAEvD,GAAKG,IAAU,EACd,OAAOP,EAAIG,EAAMC,EAAOH,EAAS,KAAMI,CAAK,EAE7CL,EAAIG,EAAMC,EAAOC,EAAMC,CAAK,CAC7B,CAKAP,EAAO,QAAUG,IC/DjB,IAAAM,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAO,QAAS,IAAK,EAAE,SACvBC,EAAW,IAsBf,SAASC,EAAUC,EAAMC,EAAOC,EAAO,CACtC,IAAIC,EACAC,EAEJD,EAAQ,UAAU,OAClB,GAAI,CACEA,IAAU,EACdC,EAAKP,EAAMG,EAAMF,EAAS,MAAOA,EAAS,IAAK,EACpCK,IAAU,EACrBC,EAAKP,EAAMG,EAAMC,EAAOH,EAAS,IAAK,EAEtCM,EAAKP,EAAMG,EAAMC,EAAOC,CAAK,CAE/B,OAAUG,EAAM,CACf,OAAOA,CACR,CACA,OAAOD,CACR,CAKAR,EAAO,QAAUG,ICjBjB,IAAIO,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAO,IAKXF,EAAaC,EAAM,OAAQC,CAAK,EAKhC,OAAO,QAAUD", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_main", "__commonJSMin", "exports", "module", "op", "defaults", "open", "path", "flags", "mode", "clbk", "nargs", "require_sync", "__commonJSMin", "exports", "module", "open", "defaults", "openSync", "path", "flags", "mode", "nargs", "fd", "err", "setReadOnly", "main", "sync"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4cbf7ac..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,65 +0,0 @@ - -{{alias}}( path[, flags[, mode]], clbk ) - Asynchronously opens a file. - - Some characters, such as <>:"/\|?*, are reserved under Windows. - Under NTFS, if the path contains a colon, Node.js will open a file system - stream. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - clbk: Function - Callback to invoke upon opening a file. - - Examples - -------- - > function onOpen( error, fd ) { - ... if ( error ) { - ... console.error( error.message ); - ... } else { - ... {{alias:@stdlib/fs/close}}.sync( fd ); - ... } - ... }; - > {{alias}}( './beep/boop.txt', onOpen ); - - -{{alias}}.sync( path[, flags[, mode]] ) - Synchronously opens a file. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - Returns - ------- - fd: Error|integer - File descriptor. - - Examples - -------- - > var fd = {{alias}}.sync( './beep/boop.txt' ); - > if ( !{{alias:@stdlib/assert/is-error}}( fd ) ) { {{alias:@stdlib/fs/close}}.sync( fd ); }; - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 67907a2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,129 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 open = require( './index' ); - -const done = ( error: Error, fd: number ) => { - if ( error || !fd ) { - throw error; - } -}; - - -// TESTS // - -// The function does not have a return value... -{ - open( '/path/to/beepboop', done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a string... -{ - open( 123, done ); // $ExpectError - open( false, done ); // $ExpectError - open( true, done ); // $ExpectError - open( null, done ); // $ExpectError - open( undefined, done ); // $ExpectError - open( [], done ); // $ExpectError - open( {}, done ); // $ExpectError - open( ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a last argument which is not a function with the expected signature... -{ - open( '/path/to/beepboop', 'abc' ); // $ExpectError - open( '/path/to/beepboop', 123 ); // $ExpectError - open( '/path/to/beepboop', false ); // $ExpectError - open( '/path/to/beepboop', true ); // $ExpectError - open( '/path/to/beepboop', null ); // $ExpectError - open( '/path/to/beepboop', undefined ); // $ExpectError - open( '/path/to/beepboop', [] ); // $ExpectError - open( '/path/to/beepboop', {} ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `flags` argument which is not a string or number... -{ - open( '/path/to/beepboop', false, done ); // $ExpectError - open( '/path/to/beepboop', true, done ); // $ExpectError - open( '/path/to/beepboop', null, done ); // $ExpectError - open( '/path/to/beepboop', undefined, done ); // $ExpectError - open( '/path/to/beepboop', [], done ); // $ExpectError - open( '/path/to/beepboop', {}, done ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` argument which is not a number... -{ - open( '/path/to/beepboop', 'r+', 'abc', done ); // $ExpectError - open( '/path/to/beepboop', 'r+', false, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', true, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', null, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', undefined, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', [], done ); // $ExpectError - open( '/path/to/beepboop', 'r+', {}, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - open(); // $ExpectError - open( 'C:\\foo\\bar\\baz' ); // $ExpectError -} - -// Attached to main export is a `sync` method which returns a number or an error... -{ - open.sync( '/path/to/beepboop' ); // $ExpectType number | Error -} - -// The compiler throws an error if the `sync` method is provided a first argument which is not a string... -{ - open.sync( 123 ); // $ExpectError - open.sync( false ); // $ExpectError - open.sync( true ); // $ExpectError - open.sync( null ); // $ExpectError - open.sync( undefined ); // $ExpectError - open.sync( [] ); // $ExpectError - open.sync( {} ); // $ExpectError - open.sync( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a second argument which is not a string or number... -{ - open.sync( '/path/to/beepboop', false ); // $ExpectError - open.sync( '/path/to/beepboop', true ); // $ExpectError - open.sync( '/path/to/beepboop', null ); // $ExpectError - open.sync( '/path/to/beepboop', [] ); // $ExpectError - open.sync( '/path/to/beepboop', {} ); // $ExpectError - open.sync( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a third argument which is not a number... -{ - open.sync( '/path/to/beepboop', 'r+', false ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', true ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', null ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', [] ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', {} ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided an unsupported number of arguments... -{ - open.sync(); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 71359fe..0000000 --- a/examples/index.js +++ /dev/null @@ -1,56 +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. -*/ - -'use strict'; - -var closeSync = require( '@stdlib/fs-close' ).sync; -var isError = require( '@stdlib/assert-is-error' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - -/* Sync */ - -var fd = open.sync( __filename, 'r+' ); -// returns - -console.log( isError( fd ) ); -// => false - -closeSync( fd ); - -fd = open.sync( 'beepboop' ); -// returns - -console.log( isError( fd ) ); -// => true - -/* Async */ - -open( __filename, onOpen ); -open( 'beepboop', onOpen ); - -function onOpen( error, fd ) { - if ( error ) { - if ( error.code === 'ENOENT' ) { - console.error( 'File does not exist.' ); - } else { - throw error; - } - } else { - closeSync( fd ); - } -} 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..bdb76ee --- /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/utils-define-nonenumerable-read-only-property@esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){if(this instanceof e){var n=[null];n.push.apply(n,arguments);var r=Function.bind.apply(t,n);return new r}return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}var n=t(Object.freeze({__proto__:null,default:{}})),r="r",o=438,u=n.open;function i(e,t,n,i){var a=arguments.length;return 2===a?u(e,r,o,t):3===a?u(e,t,o,n):void u(e,t,n,i)}var a=n.openSync;function p(e,t,n){var u,i;u=arguments.length;try{i=1===u?a(e,r,o):a(e,t,2===u?o:n)}catch(e){return e}return i}e(i,"sync",p);export{i as default,p as sync}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..e41289c --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;0pBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAIzB,CAFC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index cb174b7..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "flags": "r", - "mode": 438 -} diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 8edd6de..0000000 --- a/lib/index.js +++ /dev/null @@ -1,63 +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. -*/ - -'use strict'; - -/** -* Open a file. -* -* @module @stdlib/fs-open -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var openSync = require( '@stdlib/fs-open' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var sync = require( './sync.js' ); - - -// MAIN // - -setReadOnly( main, 'sync', sync ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index feb5171..0000000 --- a/lib/main.js +++ /dev/null @@ -1,64 +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. -*/ - -'use strict'; - -// MODULES // - -var op = require( 'fs' ).open; -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Asynchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @param {Function} clbk - callback to invoke after opening a file -* @returns {void} -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -*/ -function open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare - var nargs = arguments.length; - if ( nargs === 2 ) { - return op( path, defaults.flags, defaults.mode, flags ); - } - if ( nargs === 3 ) { - return op( path, flags, defaults.mode, mode ); - } - op( path, flags, mode, clbk ); -} - - -// EXPORTS // - -module.exports = open; diff --git a/lib/sync.js b/lib/sync.js deleted file mode 100644 index d8d2e00..0000000 --- a/lib/sync.js +++ /dev/null @@ -1,68 +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. -*/ - -'use strict'; - -// MODULES // - -var open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Synchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @returns {(integer|Error)} file descriptor or an error -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -function openSync( path, flags, mode ) { - var nargs; - var fd; - - nargs = arguments.length; - try { - if ( nargs === 1 ) { - fd = open( path, defaults.flags, defaults.mode ); - } else if ( nargs === 2 ) { - fd = open( path, flags, defaults.mode ); - } else { - fd = open( path, flags, mode ); - } - } catch ( err ) { - return err; - } - return fd; -} - - -// EXPORTS // - -module.exports = openSync; diff --git a/package.json b/package.json index 8c63011..443420d 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Open a file.", "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/utils-define-nonenumerable-read-only-property": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.0" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.0.8", - "@stdlib/assert-is-error": "^0.0.8", - "@stdlib/assert-is-nonnegative-integer": "^0.0.7", - "@stdlib/bench": "^0.0.12", - "@stdlib/fs-close": "^0.0.7", - "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", "stdfs", @@ -82,4 +30,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..8f11699 --- /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 3c47135..0000000 --- a/test/test.js +++ /dev/null @@ -1,38 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is a function to open a file synchronously', function test( t ) { - t.equal( typeof open.sync, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 33b938f..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,110 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/main.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - open( __filename, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - open( __filename, 'r+', onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - open( __filename, 'r+', 438, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - open( 'beepboopbapbop', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', 438, onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); diff --git a/test/test.sync.js b/test/test.sync.js deleted file mode 100644 index 56d7b23..0000000 --- a/test/test.sync.js +++ /dev/null @@ -1,83 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/sync.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - var fd = open( __filename ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - var fd = open( __filename, 'r+' ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - var fd = open( __filename, 'r+', 438 ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - var fd = open( 'beepboopbapbop' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+', 438 ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); From b4b575a8c85165d3625426643ed909b7b02cfa21 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 22 Sep 2023 05:01:54 +0000 Subject: [PATCH 035/113] Update README.md for ESM bundle v0.1.0 --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4067982..2385cd3 100644 --- a/README.md +++ b/README.md @@ -44,13 +44,13 @@ limitations under the License. ```javascript -import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@esm/index.mjs'; +import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@v0.1.0-esm/index.mjs'; ``` You can also import the following named exports from the package: ```javascript -import { sync } from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@esm/index.mjs'; +import { sync } from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@v0.1.0-esm/index.mjs'; ``` #### open( path\[, flags\[, mode]], clbk ) @@ -123,7 +123,7 @@ The function has the same default parameters as [`fs.openSync()`][node-fs]. ```javascript - import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@esm/index.mjs'; + import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@v0.1.0-esm/index.mjs'; var fpath = '/path/to/file.js'; @@ -155,7 +155,7 @@ The function has the same default parameters as [`fs.openSync()`][node-fs]. var join = require( 'path' ).join; var closeSync = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-close' ).sync; -import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@esm/index.mjs'; +import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@v0.1.0-esm/index.mjs'; /* Sync */ From 28a5578fa373a36fc24c865426420b83940061a2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 22 Sep 2023 05:01:55 +0000 Subject: [PATCH 036/113] Auto-generated commit --- README.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2385cd3..aba657d 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,11 @@ limitations under the License. +```javascript +import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@esm/index.mjs'; +``` +The previous example will load the latest bundled code from the esm branch. Alternatively, you may load a specific version by loading the file from one of the [tagged bundles](https://github.com/stdlib-js/fs-open/tags). For example, + ```javascript import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@v0.1.0-esm/index.mjs'; ``` @@ -50,7 +55,7 @@ import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@v0.1.0-esm/index You can also import the following named exports from the package: ```javascript -import { sync } from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@v0.1.0-esm/index.mjs'; +import { sync } from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@esm/index.mjs'; ``` #### open( path\[, flags\[, mode]], clbk ) @@ -123,7 +128,7 @@ The function has the same default parameters as [`fs.openSync()`][node-fs]. ```javascript - import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@v0.1.0-esm/index.mjs'; + import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@esm/index.mjs'; var fpath = '/path/to/file.js'; @@ -155,7 +160,7 @@ The function has the same default parameters as [`fs.openSync()`][node-fs]. var join = require( 'path' ).join; var closeSync = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-close' ).sync; -import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@v0.1.0-esm/index.mjs'; +import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@esm/index.mjs'; /* Sync */ From 8a9ca7e5ff76744e22ffe1f1398aefe926b46e05 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Oct 2023 01:09:20 +0000 Subject: [PATCH 037/113] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9883201..c29eef2 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.0" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.0" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.1.0", @@ -81,4 +82,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From e9679c7ad5c7f79fdf31e053e430b08bf9a2f22c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Oct 2023 05:33:14 +0000 Subject: [PATCH 038/113] Remove files --- index.d.ts | 150 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6332 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 eb67b7a..0000000 --- a/index.d.ts +++ /dev/null @@ -1,150 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Buffer } from 'buffer'; - -/** -* Callback invoked after opening a file. -* -* @param err - error argument -* @param fd - file descriptor -*/ -type Callback = ( err: Error, fd: number ) => void; - -/** -* Interface for opening a file. -*/ -interface Open { - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', 438, onOpen ); - */ - ( path: string | Buffer, flags: string | number, mode: number, clbk: Callback ): void; // tslint-disable-line max-line-length - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', onOpen ); - */ - ( path: string | Buffer, flags: string | number, clbk: Callback ): void; - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, onOpen ); - */ - ( path: string | Buffer, clbk: Callback ): void; - - /** - * Synchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @returns file descriptor or an error - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * var fd = open.sync( __filename, 'r+' ); - * if ( fd instanceof Error ) { - * throw fd; - * } - * closeSync( fd ); - */ - sync( path: string | Buffer, flags?: string | number, mode?: number ): number | Error; // tslint-disable-line max-line-length -} - -/** -* Asynchronously opens a file. -* -* @param path - file path -* @param flags - file system flags (default: 'r') -* @param mode - file mode (default: 0o666) -* @param clbk - callback to invoke after opening a file -* -* @example -* var closeSync = require( `@stdlib/fs/close` ).sync; -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( `@stdlib/fs/close` ).sync; -* -* var fd = open.sync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -declare var open: Open; - - -// EXPORTS // - -export = open; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index bdb76ee..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/utils-define-nonenumerable-read-only-property@esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){if(this instanceof e){var n=[null];n.push.apply(n,arguments);var r=Function.bind.apply(t,n);return new r}return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}var n=t(Object.freeze({__proto__:null,default:{}})),r="r",o=438,u=n.open;function i(e,t,n,i){var a=arguments.length;return 2===a?u(e,r,o,t):3===a?u(e,t,o,n):void u(e,t,n,i)}var a=n.openSync;function p(e,t,n){var u,i;u=arguments.length;try{i=1===u?a(e,r,o):a(e,t,2===u?o:n)}catch(e){return e}return i}e(i,"sync",p);export{i as default,p as sync}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index e41289c..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;0pBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAIzB,CAFC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 8f11699..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 76533cb975b923130ed49f719012788041e72e2a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Oct 2023 05:34:00 +0000 Subject: [PATCH 039/113] 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 | 53 +- benchmark/benchmark.js | 77 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 65 - docs/types/test.ts | 129 - examples/index.js | 56 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/defaults.json | 4 - lib/index.js | 63 - lib/main.js | 64 - lib/sync.js | 68 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 38 - test/test.js | 38 - test/test.main.js | 110 - test/test.sync.js | 83 - 46 files changed, 6211 insertions(+), 4107 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/defaults.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/sync.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.sync.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 cb524c6..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-10-01T00:44:06.239Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index a3a4470..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/fs/open) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 7617ad3..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/fs/open) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 664f5c5..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: '14 2 * * 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 + + ```
@@ -223,7 +222,7 @@ function onOpen( error, fd ) { ## 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]. @@ -287,11 +286,11 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close +[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close/tree/esm -[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists +[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists/tree/esm -[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file +[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 567aec3..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,77 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var closeSync = require( '@stdlib/fs-close' ).sync; -var pkg = require( './../package.json' ).name; -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return open( __filename, 'r+', done ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function done( error, fd ) { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - if ( error ) { - b.fail( error.message ); - } - next(); - } -}); - -bench( pkg+':sync', function benchmark( b ) { - var fd; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - fd = open.sync( __filename, 'r+' ); - if ( fd instanceof Error ) { - b.fail( fd.message ); - } else { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - } - } - b.toc(); - if ( fd instanceof Error ) { - b.fail( 'something went wrong' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index fa29fdf..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/fs/open" -%% click B href "https://github.com/stdlib-js/fs-open/tree/main" -%% click C href "https://github.com/stdlib-js/fs-open/tree/production" -%% click D href "https://github.com/stdlib-js/fs-open/tree/esm" -%% click E href "https://github.com/stdlib-js/fs-open/tree/deno" -%% click F href "https://github.com/stdlib-js/fs-open/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/fs/open -[production-url]: https://github.com/stdlib-js/fs-open/tree/production -[deno-url]: https://github.com/stdlib-js/fs-open/tree/deno -[umd-url]: https://github.com/stdlib-js/fs-open/tree/umd -[esm-url]: https://github.com/stdlib-js/fs-open/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 3e10601..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import open from '../docs/types/index'; -export = open; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 5358415..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var u=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var i=u(function(b,y){y.exports={flags:"r",mode:438}});var d=u(function(j,f){ -var a=require("fs").open,o=i();function p(r,e,t,s){var n=arguments.length;if(n===2)return a(r,o.flags,o.mode,e);if(n===3)return a(r,e,o.mode,t);a(r,e,t,s)}f.exports=p -});var m=u(function(k,l){ -var c=require("fs").openSync,v=i();function x(r,e,t){var s,n;s=arguments.length;try{s===1?n=c(r,v.flags,v.mode):s===2?n=c(r,e,v.mode):n=c(r,e,t)}catch(g){return g}return n}l.exports=x -});var S=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),q=d(),O=m();S(q,"sync",O);module.exports=q; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 65b6278..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/main.js", "../lib/sync.js", "../lib/index.js"], - "sourcesContent": ["{\n\t\"flags\": \"r\",\n\t\"mode\": 438\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var open = require( '@stdlib/fs-open' );\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nmodule.exports = open;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nmodule.exports = openSync;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var open = require( '@stdlib/fs-open' );\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var openSync = require( '@stdlib/fs-open' ).sync;\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar sync = require( './sync.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,CAAAA,EAAA,SACC,MAAS,IACT,KAAQ,GACT,ICHA,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAK,QAAS,IAAK,EAAE,KACrBC,EAAW,IA0Bf,SAASC,EAAMC,EAAMC,EAAOC,EAAMC,EAAO,CACxC,IAAIC,EAAQ,UAAU,OACtB,GAAKA,IAAU,EACd,OAAOP,EAAIG,EAAMF,EAAS,MAAOA,EAAS,KAAMG,CAAM,EAEvD,GAAKG,IAAU,EACd,OAAOP,EAAIG,EAAMC,EAAOH,EAAS,KAAMI,CAAK,EAE7CL,EAAIG,EAAMC,EAAOC,EAAMC,CAAK,CAC7B,CAKAP,EAAO,QAAUG,IC/DjB,IAAAM,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAO,QAAS,IAAK,EAAE,SACvBC,EAAW,IAsBf,SAASC,EAAUC,EAAMC,EAAOC,EAAO,CACtC,IAAIC,EACAC,EAEJD,EAAQ,UAAU,OAClB,GAAI,CACEA,IAAU,EACdC,EAAKP,EAAMG,EAAMF,EAAS,MAAOA,EAAS,IAAK,EACpCK,IAAU,EACrBC,EAAKP,EAAMG,EAAMC,EAAOH,EAAS,IAAK,EAEtCM,EAAKP,EAAMG,EAAMC,EAAOC,CAAK,CAE/B,OAAUG,EAAM,CACf,OAAOA,CACR,CACA,OAAOD,CACR,CAKAR,EAAO,QAAUG,ICjBjB,IAAIO,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAO,IAKXF,EAAaC,EAAM,OAAQC,CAAK,EAKhC,OAAO,QAAUD", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_main", "__commonJSMin", "exports", "module", "op", "defaults", "open", "path", "flags", "mode", "clbk", "nargs", "require_sync", "__commonJSMin", "exports", "module", "open", "defaults", "openSync", "path", "flags", "mode", "nargs", "fd", "err", "setReadOnly", "main", "sync"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4cbf7ac..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,65 +0,0 @@ - -{{alias}}( path[, flags[, mode]], clbk ) - Asynchronously opens a file. - - Some characters, such as <>:"/\|?*, are reserved under Windows. - Under NTFS, if the path contains a colon, Node.js will open a file system - stream. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - clbk: Function - Callback to invoke upon opening a file. - - Examples - -------- - > function onOpen( error, fd ) { - ... if ( error ) { - ... console.error( error.message ); - ... } else { - ... {{alias:@stdlib/fs/close}}.sync( fd ); - ... } - ... }; - > {{alias}}( './beep/boop.txt', onOpen ); - - -{{alias}}.sync( path[, flags[, mode]] ) - Synchronously opens a file. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - Returns - ------- - fd: Error|integer - File descriptor. - - Examples - -------- - > var fd = {{alias}}.sync( './beep/boop.txt' ); - > if ( !{{alias:@stdlib/assert/is-error}}( fd ) ) { {{alias:@stdlib/fs/close}}.sync( fd ); }; - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 67907a2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,129 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 open = require( './index' ); - -const done = ( error: Error, fd: number ) => { - if ( error || !fd ) { - throw error; - } -}; - - -// TESTS // - -// The function does not have a return value... -{ - open( '/path/to/beepboop', done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a string... -{ - open( 123, done ); // $ExpectError - open( false, done ); // $ExpectError - open( true, done ); // $ExpectError - open( null, done ); // $ExpectError - open( undefined, done ); // $ExpectError - open( [], done ); // $ExpectError - open( {}, done ); // $ExpectError - open( ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a last argument which is not a function with the expected signature... -{ - open( '/path/to/beepboop', 'abc' ); // $ExpectError - open( '/path/to/beepboop', 123 ); // $ExpectError - open( '/path/to/beepboop', false ); // $ExpectError - open( '/path/to/beepboop', true ); // $ExpectError - open( '/path/to/beepboop', null ); // $ExpectError - open( '/path/to/beepboop', undefined ); // $ExpectError - open( '/path/to/beepboop', [] ); // $ExpectError - open( '/path/to/beepboop', {} ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `flags` argument which is not a string or number... -{ - open( '/path/to/beepboop', false, done ); // $ExpectError - open( '/path/to/beepboop', true, done ); // $ExpectError - open( '/path/to/beepboop', null, done ); // $ExpectError - open( '/path/to/beepboop', undefined, done ); // $ExpectError - open( '/path/to/beepboop', [], done ); // $ExpectError - open( '/path/to/beepboop', {}, done ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` argument which is not a number... -{ - open( '/path/to/beepboop', 'r+', 'abc', done ); // $ExpectError - open( '/path/to/beepboop', 'r+', false, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', true, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', null, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', undefined, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', [], done ); // $ExpectError - open( '/path/to/beepboop', 'r+', {}, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - open(); // $ExpectError - open( 'C:\\foo\\bar\\baz' ); // $ExpectError -} - -// Attached to main export is a `sync` method which returns a number or an error... -{ - open.sync( '/path/to/beepboop' ); // $ExpectType number | Error -} - -// The compiler throws an error if the `sync` method is provided a first argument which is not a string... -{ - open.sync( 123 ); // $ExpectError - open.sync( false ); // $ExpectError - open.sync( true ); // $ExpectError - open.sync( null ); // $ExpectError - open.sync( undefined ); // $ExpectError - open.sync( [] ); // $ExpectError - open.sync( {} ); // $ExpectError - open.sync( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a second argument which is not a string or number... -{ - open.sync( '/path/to/beepboop', false ); // $ExpectError - open.sync( '/path/to/beepboop', true ); // $ExpectError - open.sync( '/path/to/beepboop', null ); // $ExpectError - open.sync( '/path/to/beepboop', [] ); // $ExpectError - open.sync( '/path/to/beepboop', {} ); // $ExpectError - open.sync( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a third argument which is not a number... -{ - open.sync( '/path/to/beepboop', 'r+', false ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', true ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', null ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', [] ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', {} ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided an unsupported number of arguments... -{ - open.sync(); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 71359fe..0000000 --- a/examples/index.js +++ /dev/null @@ -1,56 +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. -*/ - -'use strict'; - -var closeSync = require( '@stdlib/fs-close' ).sync; -var isError = require( '@stdlib/assert-is-error' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - -/* Sync */ - -var fd = open.sync( __filename, 'r+' ); -// returns - -console.log( isError( fd ) ); -// => false - -closeSync( fd ); - -fd = open.sync( 'beepboop' ); -// returns - -console.log( isError( fd ) ); -// => true - -/* Async */ - -open( __filename, onOpen ); -open( 'beepboop', onOpen ); - -function onOpen( error, fd ) { - if ( error ) { - if ( error.code === 'ENOENT' ) { - console.error( 'File does not exist.' ); - } else { - throw error; - } - } else { - closeSync( fd ); - } -} 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..d231c44 --- /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/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){if(this instanceof e){var n=[null];n.push.apply(n,arguments);var r=Function.bind.apply(t,n);return new r}return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}var n=t(Object.freeze({__proto__:null,default:{}})),r="r",o=438,u=n.open;function i(e,t,n,i){var a=arguments.length;return 2===a?u(e,r,o,t):3===a?u(e,t,o,n):void u(e,t,n,i)}var a=n.openSync;function p(e,t,n){var u,i;u=arguments.length;try{i=1===u?a(e,r,o):a(e,t,2===u?o:n)}catch(e){return e}return i}e(i,"sync",p);export{i as default,p as sync}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..5fee640 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;iqBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAIzB,CAFC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index cb174b7..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "flags": "r", - "mode": 438 -} diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 8edd6de..0000000 --- a/lib/index.js +++ /dev/null @@ -1,63 +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. -*/ - -'use strict'; - -/** -* Open a file. -* -* @module @stdlib/fs-open -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var openSync = require( '@stdlib/fs-open' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var sync = require( './sync.js' ); - - -// MAIN // - -setReadOnly( main, 'sync', sync ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index feb5171..0000000 --- a/lib/main.js +++ /dev/null @@ -1,64 +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. -*/ - -'use strict'; - -// MODULES // - -var op = require( 'fs' ).open; -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Asynchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @param {Function} clbk - callback to invoke after opening a file -* @returns {void} -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -*/ -function open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare - var nargs = arguments.length; - if ( nargs === 2 ) { - return op( path, defaults.flags, defaults.mode, flags ); - } - if ( nargs === 3 ) { - return op( path, flags, defaults.mode, mode ); - } - op( path, flags, mode, clbk ); -} - - -// EXPORTS // - -module.exports = open; diff --git a/lib/sync.js b/lib/sync.js deleted file mode 100644 index d8d2e00..0000000 --- a/lib/sync.js +++ /dev/null @@ -1,68 +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. -*/ - -'use strict'; - -// MODULES // - -var open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Synchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @returns {(integer|Error)} file descriptor or an error -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -function openSync( path, flags, mode ) { - var nargs; - var fd; - - nargs = arguments.length; - try { - if ( nargs === 1 ) { - fd = open( path, defaults.flags, defaults.mode ); - } else if ( nargs === 2 ) { - fd = open( path, flags, defaults.mode ); - } else { - fd = open( path, flags, mode ); - } - } catch ( err ) { - return err; - } - return fd; -} - - -// EXPORTS // - -module.exports = openSync; diff --git a/package.json b/package.json index c29eef2..443420d 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Open a file.", "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/utils-define-nonenumerable-read-only-property": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.0" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.1.0", - "@stdlib/assert-is-error": "^0.1.0", - "@stdlib/assert-is-nonnegative-integer": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/fs-close": "^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", "stdfs", @@ -82,4 +30,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..5ad43a6 --- /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 e8a1683..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,38 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var open = require( './../../dist' ); // eslint-disable-line stdlib/no-redeclare - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is a function to open a file synchronously', function test( t ) { - t.equal( typeof open.sync, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 3c47135..0000000 --- a/test/test.js +++ /dev/null @@ -1,38 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is a function to open a file synchronously', function test( t ) { - t.equal( typeof open.sync, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 33b938f..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,110 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/main.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - open( __filename, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - open( __filename, 'r+', onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - open( __filename, 'r+', 438, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - open( 'beepboopbapbop', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', 438, onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); diff --git a/test/test.sync.js b/test/test.sync.js deleted file mode 100644 index 56d7b23..0000000 --- a/test/test.sync.js +++ /dev/null @@ -1,83 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/sync.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - var fd = open( __filename ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - var fd = open( __filename, 'r+' ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - var fd = open( __filename, 'r+', 438 ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - var fd = open( 'beepboopbapbop' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+', 438 ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); From ceaf53a2bf6a1ca2e8fc0f6b3f93cb92c42395d2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 3 Oct 2023 23:47:03 +0000 Subject: [PATCH 040/113] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 1f728e6..6890f9b 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.1.0", @@ -81,4 +82,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From aeaecaeb95269a7c300975c4f93206440e9297ce Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 4 Oct 2023 05:16:45 +0000 Subject: [PATCH 041/113] Remove files --- index.d.ts | 150 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6332 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 eb67b7a..0000000 --- a/index.d.ts +++ /dev/null @@ -1,150 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Buffer } from 'buffer'; - -/** -* Callback invoked after opening a file. -* -* @param err - error argument -* @param fd - file descriptor -*/ -type Callback = ( err: Error, fd: number ) => void; - -/** -* Interface for opening a file. -*/ -interface Open { - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', 438, onOpen ); - */ - ( path: string | Buffer, flags: string | number, mode: number, clbk: Callback ): void; // tslint-disable-line max-line-length - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', onOpen ); - */ - ( path: string | Buffer, flags: string | number, clbk: Callback ): void; - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, onOpen ); - */ - ( path: string | Buffer, clbk: Callback ): void; - - /** - * Synchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @returns file descriptor or an error - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * var fd = open.sync( __filename, 'r+' ); - * if ( fd instanceof Error ) { - * throw fd; - * } - * closeSync( fd ); - */ - sync( path: string | Buffer, flags?: string | number, mode?: number ): number | Error; // tslint-disable-line max-line-length -} - -/** -* Asynchronously opens a file. -* -* @param path - file path -* @param flags - file system flags (default: 'r') -* @param mode - file mode (default: 0o666) -* @param clbk - callback to invoke after opening a file -* -* @example -* var closeSync = require( `@stdlib/fs/close` ).sync; -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( `@stdlib/fs/close` ).sync; -* -* var fd = open.sync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -declare var open: Open; - - -// EXPORTS // - -export = open; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d231c44..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/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){if(this instanceof e){var n=[null];n.push.apply(n,arguments);var r=Function.bind.apply(t,n);return new r}return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}var n=t(Object.freeze({__proto__:null,default:{}})),r="r",o=438,u=n.open;function i(e,t,n,i){var a=arguments.length;return 2===a?u(e,r,o,t):3===a?u(e,t,o,n):void u(e,t,n,i)}var a=n.openSync;function p(e,t,n){var u,i;u=arguments.length;try{i=1===u?a(e,r,o):a(e,t,2===u?o:n)}catch(e){return e}return i}e(i,"sync",p);export{i as default,p as sync}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 5fee640..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;iqBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAIzB,CAFC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 5ad43a6..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 98ff054f5a64820a0f9a9cdd75fb102e2f9bb8f0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 4 Oct 2023 05:17:28 +0000 Subject: [PATCH 042/113] 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 | 53 +- benchmark/benchmark.js | 77 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 65 - docs/types/test.ts | 129 - examples/index.js | 56 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/defaults.json | 4 - lib/index.js | 63 - lib/main.js | 64 - lib/sync.js | 68 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 38 - test/test.js | 38 - test/test.main.js | 110 - test/test.sync.js | 83 - 45 files changed, 6211 insertions(+), 4106 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/defaults.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/sync.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.sync.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 a3a4470..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/fs/open) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 7617ad3..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/fs/open) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 664f5c5..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: '14 2 * * 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 + + ```
@@ -223,7 +222,7 @@ function onOpen( error, fd ) { ## 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]. @@ -287,11 +286,11 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close +[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close/tree/esm -[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists +[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists/tree/esm -[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file +[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 567aec3..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,77 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var closeSync = require( '@stdlib/fs-close' ).sync; -var pkg = require( './../package.json' ).name; -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return open( __filename, 'r+', done ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function done( error, fd ) { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - if ( error ) { - b.fail( error.message ); - } - next(); - } -}); - -bench( pkg+':sync', function benchmark( b ) { - var fd; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - fd = open.sync( __filename, 'r+' ); - if ( fd instanceof Error ) { - b.fail( fd.message ); - } else { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - } - } - b.toc(); - if ( fd instanceof Error ) { - b.fail( 'something went wrong' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index fa29fdf..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/fs/open" -%% click B href "https://github.com/stdlib-js/fs-open/tree/main" -%% click C href "https://github.com/stdlib-js/fs-open/tree/production" -%% click D href "https://github.com/stdlib-js/fs-open/tree/esm" -%% click E href "https://github.com/stdlib-js/fs-open/tree/deno" -%% click F href "https://github.com/stdlib-js/fs-open/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/fs/open -[production-url]: https://github.com/stdlib-js/fs-open/tree/production -[deno-url]: https://github.com/stdlib-js/fs-open/tree/deno -[umd-url]: https://github.com/stdlib-js/fs-open/tree/umd -[esm-url]: https://github.com/stdlib-js/fs-open/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 3e10601..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import open from '../docs/types/index'; -export = open; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 5358415..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var u=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var i=u(function(b,y){y.exports={flags:"r",mode:438}});var d=u(function(j,f){ -var a=require("fs").open,o=i();function p(r,e,t,s){var n=arguments.length;if(n===2)return a(r,o.flags,o.mode,e);if(n===3)return a(r,e,o.mode,t);a(r,e,t,s)}f.exports=p -});var m=u(function(k,l){ -var c=require("fs").openSync,v=i();function x(r,e,t){var s,n;s=arguments.length;try{s===1?n=c(r,v.flags,v.mode):s===2?n=c(r,e,v.mode):n=c(r,e,t)}catch(g){return g}return n}l.exports=x -});var S=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),q=d(),O=m();S(q,"sync",O);module.exports=q; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 65b6278..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/main.js", "../lib/sync.js", "../lib/index.js"], - "sourcesContent": ["{\n\t\"flags\": \"r\",\n\t\"mode\": 438\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var open = require( '@stdlib/fs-open' );\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nmodule.exports = open;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nmodule.exports = openSync;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var open = require( '@stdlib/fs-open' );\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var openSync = require( '@stdlib/fs-open' ).sync;\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar sync = require( './sync.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,CAAAA,EAAA,SACC,MAAS,IACT,KAAQ,GACT,ICHA,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAK,QAAS,IAAK,EAAE,KACrBC,EAAW,IA0Bf,SAASC,EAAMC,EAAMC,EAAOC,EAAMC,EAAO,CACxC,IAAIC,EAAQ,UAAU,OACtB,GAAKA,IAAU,EACd,OAAOP,EAAIG,EAAMF,EAAS,MAAOA,EAAS,KAAMG,CAAM,EAEvD,GAAKG,IAAU,EACd,OAAOP,EAAIG,EAAMC,EAAOH,EAAS,KAAMI,CAAK,EAE7CL,EAAIG,EAAMC,EAAOC,EAAMC,CAAK,CAC7B,CAKAP,EAAO,QAAUG,IC/DjB,IAAAM,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAO,QAAS,IAAK,EAAE,SACvBC,EAAW,IAsBf,SAASC,EAAUC,EAAMC,EAAOC,EAAO,CACtC,IAAIC,EACAC,EAEJD,EAAQ,UAAU,OAClB,GAAI,CACEA,IAAU,EACdC,EAAKP,EAAMG,EAAMF,EAAS,MAAOA,EAAS,IAAK,EACpCK,IAAU,EACrBC,EAAKP,EAAMG,EAAMC,EAAOH,EAAS,IAAK,EAEtCM,EAAKP,EAAMG,EAAMC,EAAOC,CAAK,CAE/B,OAAUG,EAAM,CACf,OAAOA,CACR,CACA,OAAOD,CACR,CAKAR,EAAO,QAAUG,ICjBjB,IAAIO,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAO,IAKXF,EAAaC,EAAM,OAAQC,CAAK,EAKhC,OAAO,QAAUD", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_main", "__commonJSMin", "exports", "module", "op", "defaults", "open", "path", "flags", "mode", "clbk", "nargs", "require_sync", "__commonJSMin", "exports", "module", "open", "defaults", "openSync", "path", "flags", "mode", "nargs", "fd", "err", "setReadOnly", "main", "sync"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4cbf7ac..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,65 +0,0 @@ - -{{alias}}( path[, flags[, mode]], clbk ) - Asynchronously opens a file. - - Some characters, such as <>:"/\|?*, are reserved under Windows. - Under NTFS, if the path contains a colon, Node.js will open a file system - stream. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - clbk: Function - Callback to invoke upon opening a file. - - Examples - -------- - > function onOpen( error, fd ) { - ... if ( error ) { - ... console.error( error.message ); - ... } else { - ... {{alias:@stdlib/fs/close}}.sync( fd ); - ... } - ... }; - > {{alias}}( './beep/boop.txt', onOpen ); - - -{{alias}}.sync( path[, flags[, mode]] ) - Synchronously opens a file. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - Returns - ------- - fd: Error|integer - File descriptor. - - Examples - -------- - > var fd = {{alias}}.sync( './beep/boop.txt' ); - > if ( !{{alias:@stdlib/assert/is-error}}( fd ) ) { {{alias:@stdlib/fs/close}}.sync( fd ); }; - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 67907a2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,129 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 open = require( './index' ); - -const done = ( error: Error, fd: number ) => { - if ( error || !fd ) { - throw error; - } -}; - - -// TESTS // - -// The function does not have a return value... -{ - open( '/path/to/beepboop', done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a string... -{ - open( 123, done ); // $ExpectError - open( false, done ); // $ExpectError - open( true, done ); // $ExpectError - open( null, done ); // $ExpectError - open( undefined, done ); // $ExpectError - open( [], done ); // $ExpectError - open( {}, done ); // $ExpectError - open( ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a last argument which is not a function with the expected signature... -{ - open( '/path/to/beepboop', 'abc' ); // $ExpectError - open( '/path/to/beepboop', 123 ); // $ExpectError - open( '/path/to/beepboop', false ); // $ExpectError - open( '/path/to/beepboop', true ); // $ExpectError - open( '/path/to/beepboop', null ); // $ExpectError - open( '/path/to/beepboop', undefined ); // $ExpectError - open( '/path/to/beepboop', [] ); // $ExpectError - open( '/path/to/beepboop', {} ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `flags` argument which is not a string or number... -{ - open( '/path/to/beepboop', false, done ); // $ExpectError - open( '/path/to/beepboop', true, done ); // $ExpectError - open( '/path/to/beepboop', null, done ); // $ExpectError - open( '/path/to/beepboop', undefined, done ); // $ExpectError - open( '/path/to/beepboop', [], done ); // $ExpectError - open( '/path/to/beepboop', {}, done ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` argument which is not a number... -{ - open( '/path/to/beepboop', 'r+', 'abc', done ); // $ExpectError - open( '/path/to/beepboop', 'r+', false, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', true, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', null, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', undefined, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', [], done ); // $ExpectError - open( '/path/to/beepboop', 'r+', {}, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - open(); // $ExpectError - open( 'C:\\foo\\bar\\baz' ); // $ExpectError -} - -// Attached to main export is a `sync` method which returns a number or an error... -{ - open.sync( '/path/to/beepboop' ); // $ExpectType number | Error -} - -// The compiler throws an error if the `sync` method is provided a first argument which is not a string... -{ - open.sync( 123 ); // $ExpectError - open.sync( false ); // $ExpectError - open.sync( true ); // $ExpectError - open.sync( null ); // $ExpectError - open.sync( undefined ); // $ExpectError - open.sync( [] ); // $ExpectError - open.sync( {} ); // $ExpectError - open.sync( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a second argument which is not a string or number... -{ - open.sync( '/path/to/beepboop', false ); // $ExpectError - open.sync( '/path/to/beepboop', true ); // $ExpectError - open.sync( '/path/to/beepboop', null ); // $ExpectError - open.sync( '/path/to/beepboop', [] ); // $ExpectError - open.sync( '/path/to/beepboop', {} ); // $ExpectError - open.sync( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a third argument which is not a number... -{ - open.sync( '/path/to/beepboop', 'r+', false ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', true ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', null ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', [] ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', {} ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided an unsupported number of arguments... -{ - open.sync(); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 71359fe..0000000 --- a/examples/index.js +++ /dev/null @@ -1,56 +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. -*/ - -'use strict'; - -var closeSync = require( '@stdlib/fs-close' ).sync; -var isError = require( '@stdlib/assert-is-error' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - -/* Sync */ - -var fd = open.sync( __filename, 'r+' ); -// returns - -console.log( isError( fd ) ); -// => false - -closeSync( fd ); - -fd = open.sync( 'beepboop' ); -// returns - -console.log( isError( fd ) ); -// => true - -/* Async */ - -open( __filename, onOpen ); -open( 'beepboop', onOpen ); - -function onOpen( error, fd ) { - if ( error ) { - if ( error.code === 'ENOENT' ) { - console.error( 'File does not exist.' ); - } else { - throw error; - } - } else { - closeSync( fd ); - } -} 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..d231c44 --- /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/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){if(this instanceof e){var n=[null];n.push.apply(n,arguments);var r=Function.bind.apply(t,n);return new r}return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}var n=t(Object.freeze({__proto__:null,default:{}})),r="r",o=438,u=n.open;function i(e,t,n,i){var a=arguments.length;return 2===a?u(e,r,o,t):3===a?u(e,t,o,n):void u(e,t,n,i)}var a=n.openSync;function p(e,t,n){var u,i;u=arguments.length;try{i=1===u?a(e,r,o):a(e,t,2===u?o:n)}catch(e){return e}return i}e(i,"sync",p);export{i as default,p as sync}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..5fee640 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;iqBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAIzB,CAFC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index cb174b7..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "flags": "r", - "mode": 438 -} diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 8edd6de..0000000 --- a/lib/index.js +++ /dev/null @@ -1,63 +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. -*/ - -'use strict'; - -/** -* Open a file. -* -* @module @stdlib/fs-open -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var openSync = require( '@stdlib/fs-open' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var sync = require( './sync.js' ); - - -// MAIN // - -setReadOnly( main, 'sync', sync ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index feb5171..0000000 --- a/lib/main.js +++ /dev/null @@ -1,64 +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. -*/ - -'use strict'; - -// MODULES // - -var op = require( 'fs' ).open; -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Asynchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @param {Function} clbk - callback to invoke after opening a file -* @returns {void} -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -*/ -function open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare - var nargs = arguments.length; - if ( nargs === 2 ) { - return op( path, defaults.flags, defaults.mode, flags ); - } - if ( nargs === 3 ) { - return op( path, flags, defaults.mode, mode ); - } - op( path, flags, mode, clbk ); -} - - -// EXPORTS // - -module.exports = open; diff --git a/lib/sync.js b/lib/sync.js deleted file mode 100644 index d8d2e00..0000000 --- a/lib/sync.js +++ /dev/null @@ -1,68 +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. -*/ - -'use strict'; - -// MODULES // - -var open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Synchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @returns {(integer|Error)} file descriptor or an error -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -function openSync( path, flags, mode ) { - var nargs; - var fd; - - nargs = arguments.length; - try { - if ( nargs === 1 ) { - fd = open( path, defaults.flags, defaults.mode ); - } else if ( nargs === 2 ) { - fd = open( path, flags, defaults.mode ); - } else { - fd = open( path, flags, mode ); - } - } catch ( err ) { - return err; - } - return fd; -} - - -// EXPORTS // - -module.exports = openSync; diff --git a/package.json b/package.json index 6890f9b..337e340 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Open a file.", "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/utils-define-nonenumerable-read-only-property": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.1.0", - "@stdlib/assert-is-error": "^0.1.0", - "@stdlib/assert-is-nonnegative-integer": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/fs-close": "^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", "stdfs", @@ -82,4 +30,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..a11d5c2 --- /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 e8a1683..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,38 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var open = require( './../../dist' ); // eslint-disable-line stdlib/no-redeclare - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is a function to open a file synchronously', function test( t ) { - t.equal( typeof open.sync, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 3c47135..0000000 --- a/test/test.js +++ /dev/null @@ -1,38 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is a function to open a file synchronously', function test( t ) { - t.equal( typeof open.sync, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 33b938f..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,110 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/main.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - open( __filename, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - open( __filename, 'r+', onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - open( __filename, 'r+', 438, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - open( 'beepboopbapbop', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', 438, onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); diff --git a/test/test.sync.js b/test/test.sync.js deleted file mode 100644 index 56d7b23..0000000 --- a/test/test.sync.js +++ /dev/null @@ -1,83 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/sync.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - var fd = open( __filename ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - var fd = open( __filename, 'r+' ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - var fd = open( __filename, 'r+', 438 ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - var fd = open( 'beepboopbapbop' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+', 438 ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); From f9ca117b226b57e00729f83d4c980904aa695260 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 4 Oct 2023 09:36:39 +0000 Subject: [PATCH 043/113] Update README.md for ESM bundle v0.1.1 --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ac4f144..d0c846f 100644 --- a/README.md +++ b/README.md @@ -44,13 +44,13 @@ limitations under the License. ```javascript -import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@esm/index.mjs'; +import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@v0.1.1-esm/index.mjs'; ``` You can also import the following named exports from the package: ```javascript -import { sync } from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@esm/index.mjs'; +import { sync } from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@v0.1.1-esm/index.mjs'; ``` #### open( path\[, flags\[, mode]], clbk ) @@ -123,7 +123,7 @@ The function has the same default parameters as [`fs.openSync()`][node-fs]. ```javascript - import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@esm/index.mjs'; + import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@v0.1.1-esm/index.mjs'; var fpath = '/path/to/file.js'; @@ -155,7 +155,7 @@ The function has the same default parameters as [`fs.openSync()`][node-fs]. var join = require( 'path' ).join; var closeSync = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-close' ).sync; -import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@esm/index.mjs'; +import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@v0.1.1-esm/index.mjs'; /* Sync */ From 24830a13edd16cc8ef109d383d6559079c740251 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 4 Oct 2023 09:36:39 +0000 Subject: [PATCH 044/113] Auto-generated commit --- README.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d0c846f..e5a13d8 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,11 @@ limitations under the License. +```javascript +import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@esm/index.mjs'; +``` +The previous example will load the latest bundled code from the esm branch. Alternatively, you may load a specific version by loading the file from one of the [tagged bundles](https://github.com/stdlib-js/fs-open/tags). For example, + ```javascript import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@v0.1.1-esm/index.mjs'; ``` @@ -50,7 +55,7 @@ import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@v0.1.1-esm/index You can also import the following named exports from the package: ```javascript -import { sync } from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@v0.1.1-esm/index.mjs'; +import { sync } from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@esm/index.mjs'; ``` #### open( path\[, flags\[, mode]], clbk ) @@ -123,7 +128,7 @@ The function has the same default parameters as [`fs.openSync()`][node-fs]. ```javascript - import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@v0.1.1-esm/index.mjs'; + import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@esm/index.mjs'; var fpath = '/path/to/file.js'; @@ -155,7 +160,7 @@ The function has the same default parameters as [`fs.openSync()`][node-fs]. var join = require( 'path' ).join; var closeSync = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-close' ).sync; -import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@v0.1.1-esm/index.mjs'; +import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@esm/index.mjs'; /* Sync */ From 836c07300b914d18d3b2ebe76d015b59fded4081 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 5 Oct 2023 03:08:59 +0000 Subject: [PATCH 045/113] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index cfb2b75..d51b81e 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.1.1", @@ -81,4 +82,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From cef7ae8a856a9754df203f63877986e70728af5a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 5 Oct 2023 07:25:57 +0000 Subject: [PATCH 046/113] Remove files --- index.d.ts | 150 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6332 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 eb67b7a..0000000 --- a/index.d.ts +++ /dev/null @@ -1,150 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Buffer } from 'buffer'; - -/** -* Callback invoked after opening a file. -* -* @param err - error argument -* @param fd - file descriptor -*/ -type Callback = ( err: Error, fd: number ) => void; - -/** -* Interface for opening a file. -*/ -interface Open { - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', 438, onOpen ); - */ - ( path: string | Buffer, flags: string | number, mode: number, clbk: Callback ): void; // tslint-disable-line max-line-length - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', onOpen ); - */ - ( path: string | Buffer, flags: string | number, clbk: Callback ): void; - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, onOpen ); - */ - ( path: string | Buffer, clbk: Callback ): void; - - /** - * Synchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @returns file descriptor or an error - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * var fd = open.sync( __filename, 'r+' ); - * if ( fd instanceof Error ) { - * throw fd; - * } - * closeSync( fd ); - */ - sync( path: string | Buffer, flags?: string | number, mode?: number ): number | Error; // tslint-disable-line max-line-length -} - -/** -* Asynchronously opens a file. -* -* @param path - file path -* @param flags - file system flags (default: 'r') -* @param mode - file mode (default: 0o666) -* @param clbk - callback to invoke after opening a file -* -* @example -* var closeSync = require( `@stdlib/fs/close` ).sync; -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( `@stdlib/fs/close` ).sync; -* -* var fd = open.sync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -declare var open: Open; - - -// EXPORTS // - -export = open; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d231c44..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/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){if(this instanceof e){var n=[null];n.push.apply(n,arguments);var r=Function.bind.apply(t,n);return new r}return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}var n=t(Object.freeze({__proto__:null,default:{}})),r="r",o=438,u=n.open;function i(e,t,n,i){var a=arguments.length;return 2===a?u(e,r,o,t):3===a?u(e,t,o,n):void u(e,t,n,i)}var a=n.openSync;function p(e,t,n){var u,i;u=arguments.length;try{i=1===u?a(e,r,o):a(e,t,2===u?o:n)}catch(e){return e}return i}e(i,"sync",p);export{i as default,p as sync}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 5fee640..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;iqBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAIzB,CAFC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index a11d5c2..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From a3099795bf733b62387edf9448e2d5da70138a17 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 5 Oct 2023 07:26:46 +0000 Subject: [PATCH 047/113] 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 | 53 +- benchmark/benchmark.js | 77 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 65 - docs/types/test.ts | 129 - examples/index.js | 56 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/defaults.json | 4 - lib/index.js | 63 - lib/main.js | 64 - lib/sync.js | 68 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 38 - test/test.js | 38 - test/test.main.js | 110 - test/test.sync.js | 83 - 45 files changed, 6211 insertions(+), 4106 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/defaults.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/sync.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.sync.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 a3a4470..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/fs/open) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 7617ad3..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/fs/open) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 664f5c5..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: '14 2 * * 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 + + ```
@@ -223,7 +222,7 @@ function onOpen( error, fd ) { ## 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]. @@ -287,11 +286,11 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close +[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close/tree/esm -[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists +[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists/tree/esm -[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file +[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 567aec3..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,77 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var closeSync = require( '@stdlib/fs-close' ).sync; -var pkg = require( './../package.json' ).name; -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return open( __filename, 'r+', done ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function done( error, fd ) { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - if ( error ) { - b.fail( error.message ); - } - next(); - } -}); - -bench( pkg+':sync', function benchmark( b ) { - var fd; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - fd = open.sync( __filename, 'r+' ); - if ( fd instanceof Error ) { - b.fail( fd.message ); - } else { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - } - } - b.toc(); - if ( fd instanceof Error ) { - b.fail( 'something went wrong' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index fa29fdf..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/fs/open" -%% click B href "https://github.com/stdlib-js/fs-open/tree/main" -%% click C href "https://github.com/stdlib-js/fs-open/tree/production" -%% click D href "https://github.com/stdlib-js/fs-open/tree/esm" -%% click E href "https://github.com/stdlib-js/fs-open/tree/deno" -%% click F href "https://github.com/stdlib-js/fs-open/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/fs/open -[production-url]: https://github.com/stdlib-js/fs-open/tree/production -[deno-url]: https://github.com/stdlib-js/fs-open/tree/deno -[umd-url]: https://github.com/stdlib-js/fs-open/tree/umd -[esm-url]: https://github.com/stdlib-js/fs-open/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 3e10601..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import open from '../docs/types/index'; -export = open; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 5358415..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var u=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var i=u(function(b,y){y.exports={flags:"r",mode:438}});var d=u(function(j,f){ -var a=require("fs").open,o=i();function p(r,e,t,s){var n=arguments.length;if(n===2)return a(r,o.flags,o.mode,e);if(n===3)return a(r,e,o.mode,t);a(r,e,t,s)}f.exports=p -});var m=u(function(k,l){ -var c=require("fs").openSync,v=i();function x(r,e,t){var s,n;s=arguments.length;try{s===1?n=c(r,v.flags,v.mode):s===2?n=c(r,e,v.mode):n=c(r,e,t)}catch(g){return g}return n}l.exports=x -});var S=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),q=d(),O=m();S(q,"sync",O);module.exports=q; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 65b6278..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/main.js", "../lib/sync.js", "../lib/index.js"], - "sourcesContent": ["{\n\t\"flags\": \"r\",\n\t\"mode\": 438\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var open = require( '@stdlib/fs-open' );\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nmodule.exports = open;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nmodule.exports = openSync;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var open = require( '@stdlib/fs-open' );\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var openSync = require( '@stdlib/fs-open' ).sync;\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar sync = require( './sync.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,CAAAA,EAAA,SACC,MAAS,IACT,KAAQ,GACT,ICHA,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAK,QAAS,IAAK,EAAE,KACrBC,EAAW,IA0Bf,SAASC,EAAMC,EAAMC,EAAOC,EAAMC,EAAO,CACxC,IAAIC,EAAQ,UAAU,OACtB,GAAKA,IAAU,EACd,OAAOP,EAAIG,EAAMF,EAAS,MAAOA,EAAS,KAAMG,CAAM,EAEvD,GAAKG,IAAU,EACd,OAAOP,EAAIG,EAAMC,EAAOH,EAAS,KAAMI,CAAK,EAE7CL,EAAIG,EAAMC,EAAOC,EAAMC,CAAK,CAC7B,CAKAP,EAAO,QAAUG,IC/DjB,IAAAM,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAO,QAAS,IAAK,EAAE,SACvBC,EAAW,IAsBf,SAASC,EAAUC,EAAMC,EAAOC,EAAO,CACtC,IAAIC,EACAC,EAEJD,EAAQ,UAAU,OAClB,GAAI,CACEA,IAAU,EACdC,EAAKP,EAAMG,EAAMF,EAAS,MAAOA,EAAS,IAAK,EACpCK,IAAU,EACrBC,EAAKP,EAAMG,EAAMC,EAAOH,EAAS,IAAK,EAEtCM,EAAKP,EAAMG,EAAMC,EAAOC,CAAK,CAE/B,OAAUG,EAAM,CACf,OAAOA,CACR,CACA,OAAOD,CACR,CAKAR,EAAO,QAAUG,ICjBjB,IAAIO,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAO,IAKXF,EAAaC,EAAM,OAAQC,CAAK,EAKhC,OAAO,QAAUD", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_main", "__commonJSMin", "exports", "module", "op", "defaults", "open", "path", "flags", "mode", "clbk", "nargs", "require_sync", "__commonJSMin", "exports", "module", "open", "defaults", "openSync", "path", "flags", "mode", "nargs", "fd", "err", "setReadOnly", "main", "sync"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4cbf7ac..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,65 +0,0 @@ - -{{alias}}( path[, flags[, mode]], clbk ) - Asynchronously opens a file. - - Some characters, such as <>:"/\|?*, are reserved under Windows. - Under NTFS, if the path contains a colon, Node.js will open a file system - stream. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - clbk: Function - Callback to invoke upon opening a file. - - Examples - -------- - > function onOpen( error, fd ) { - ... if ( error ) { - ... console.error( error.message ); - ... } else { - ... {{alias:@stdlib/fs/close}}.sync( fd ); - ... } - ... }; - > {{alias}}( './beep/boop.txt', onOpen ); - - -{{alias}}.sync( path[, flags[, mode]] ) - Synchronously opens a file. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - Returns - ------- - fd: Error|integer - File descriptor. - - Examples - -------- - > var fd = {{alias}}.sync( './beep/boop.txt' ); - > if ( !{{alias:@stdlib/assert/is-error}}( fd ) ) { {{alias:@stdlib/fs/close}}.sync( fd ); }; - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 67907a2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,129 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 open = require( './index' ); - -const done = ( error: Error, fd: number ) => { - if ( error || !fd ) { - throw error; - } -}; - - -// TESTS // - -// The function does not have a return value... -{ - open( '/path/to/beepboop', done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a string... -{ - open( 123, done ); // $ExpectError - open( false, done ); // $ExpectError - open( true, done ); // $ExpectError - open( null, done ); // $ExpectError - open( undefined, done ); // $ExpectError - open( [], done ); // $ExpectError - open( {}, done ); // $ExpectError - open( ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a last argument which is not a function with the expected signature... -{ - open( '/path/to/beepboop', 'abc' ); // $ExpectError - open( '/path/to/beepboop', 123 ); // $ExpectError - open( '/path/to/beepboop', false ); // $ExpectError - open( '/path/to/beepboop', true ); // $ExpectError - open( '/path/to/beepboop', null ); // $ExpectError - open( '/path/to/beepboop', undefined ); // $ExpectError - open( '/path/to/beepboop', [] ); // $ExpectError - open( '/path/to/beepboop', {} ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `flags` argument which is not a string or number... -{ - open( '/path/to/beepboop', false, done ); // $ExpectError - open( '/path/to/beepboop', true, done ); // $ExpectError - open( '/path/to/beepboop', null, done ); // $ExpectError - open( '/path/to/beepboop', undefined, done ); // $ExpectError - open( '/path/to/beepboop', [], done ); // $ExpectError - open( '/path/to/beepboop', {}, done ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` argument which is not a number... -{ - open( '/path/to/beepboop', 'r+', 'abc', done ); // $ExpectError - open( '/path/to/beepboop', 'r+', false, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', true, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', null, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', undefined, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', [], done ); // $ExpectError - open( '/path/to/beepboop', 'r+', {}, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - open(); // $ExpectError - open( 'C:\\foo\\bar\\baz' ); // $ExpectError -} - -// Attached to main export is a `sync` method which returns a number or an error... -{ - open.sync( '/path/to/beepboop' ); // $ExpectType number | Error -} - -// The compiler throws an error if the `sync` method is provided a first argument which is not a string... -{ - open.sync( 123 ); // $ExpectError - open.sync( false ); // $ExpectError - open.sync( true ); // $ExpectError - open.sync( null ); // $ExpectError - open.sync( undefined ); // $ExpectError - open.sync( [] ); // $ExpectError - open.sync( {} ); // $ExpectError - open.sync( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a second argument which is not a string or number... -{ - open.sync( '/path/to/beepboop', false ); // $ExpectError - open.sync( '/path/to/beepboop', true ); // $ExpectError - open.sync( '/path/to/beepboop', null ); // $ExpectError - open.sync( '/path/to/beepboop', [] ); // $ExpectError - open.sync( '/path/to/beepboop', {} ); // $ExpectError - open.sync( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a third argument which is not a number... -{ - open.sync( '/path/to/beepboop', 'r+', false ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', true ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', null ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', [] ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', {} ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided an unsupported number of arguments... -{ - open.sync(); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 71359fe..0000000 --- a/examples/index.js +++ /dev/null @@ -1,56 +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. -*/ - -'use strict'; - -var closeSync = require( '@stdlib/fs-close' ).sync; -var isError = require( '@stdlib/assert-is-error' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - -/* Sync */ - -var fd = open.sync( __filename, 'r+' ); -// returns - -console.log( isError( fd ) ); -// => false - -closeSync( fd ); - -fd = open.sync( 'beepboop' ); -// returns - -console.log( isError( fd ) ); -// => true - -/* Async */ - -open( __filename, onOpen ); -open( 'beepboop', onOpen ); - -function onOpen( error, fd ) { - if ( error ) { - if ( error.code === 'ENOENT' ) { - console.error( 'File does not exist.' ); - } else { - throw error; - } - } else { - closeSync( fd ); - } -} 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..d231c44 --- /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/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){if(this instanceof e){var n=[null];n.push.apply(n,arguments);var r=Function.bind.apply(t,n);return new r}return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}var n=t(Object.freeze({__proto__:null,default:{}})),r="r",o=438,u=n.open;function i(e,t,n,i){var a=arguments.length;return 2===a?u(e,r,o,t):3===a?u(e,t,o,n):void u(e,t,n,i)}var a=n.openSync;function p(e,t,n){var u,i;u=arguments.length;try{i=1===u?a(e,r,o):a(e,t,2===u?o:n)}catch(e){return e}return i}e(i,"sync",p);export{i as default,p as sync}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..5fee640 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;iqBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAIzB,CAFC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index cb174b7..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "flags": "r", - "mode": 438 -} diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 8edd6de..0000000 --- a/lib/index.js +++ /dev/null @@ -1,63 +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. -*/ - -'use strict'; - -/** -* Open a file. -* -* @module @stdlib/fs-open -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var openSync = require( '@stdlib/fs-open' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var sync = require( './sync.js' ); - - -// MAIN // - -setReadOnly( main, 'sync', sync ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index feb5171..0000000 --- a/lib/main.js +++ /dev/null @@ -1,64 +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. -*/ - -'use strict'; - -// MODULES // - -var op = require( 'fs' ).open; -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Asynchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @param {Function} clbk - callback to invoke after opening a file -* @returns {void} -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -*/ -function open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare - var nargs = arguments.length; - if ( nargs === 2 ) { - return op( path, defaults.flags, defaults.mode, flags ); - } - if ( nargs === 3 ) { - return op( path, flags, defaults.mode, mode ); - } - op( path, flags, mode, clbk ); -} - - -// EXPORTS // - -module.exports = open; diff --git a/lib/sync.js b/lib/sync.js deleted file mode 100644 index d8d2e00..0000000 --- a/lib/sync.js +++ /dev/null @@ -1,68 +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. -*/ - -'use strict'; - -// MODULES // - -var open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Synchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @returns {(integer|Error)} file descriptor or an error -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -function openSync( path, flags, mode ) { - var nargs; - var fd; - - nargs = arguments.length; - try { - if ( nargs === 1 ) { - fd = open( path, defaults.flags, defaults.mode ); - } else if ( nargs === 2 ) { - fd = open( path, flags, defaults.mode ); - } else { - fd = open( path, flags, mode ); - } - } catch ( err ) { - return err; - } - return fd; -} - - -// EXPORTS // - -module.exports = openSync; diff --git a/package.json b/package.json index d51b81e..337e340 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Open a file.", "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/utils-define-nonenumerable-read-only-property": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.1.1", - "@stdlib/assert-is-error": "^0.1.1", - "@stdlib/assert-is-nonnegative-integer": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/fs-close": "^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", "stdfs", @@ -82,4 +30,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..5445ce0 --- /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 e8a1683..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,38 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var open = require( './../../dist' ); // eslint-disable-line stdlib/no-redeclare - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is a function to open a file synchronously', function test( t ) { - t.equal( typeof open.sync, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 3c47135..0000000 --- a/test/test.js +++ /dev/null @@ -1,38 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is a function to open a file synchronously', function test( t ) { - t.equal( typeof open.sync, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 33b938f..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,110 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/main.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - open( __filename, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - open( __filename, 'r+', onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - open( __filename, 'r+', 438, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - open( 'beepboopbapbop', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', 438, onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); diff --git a/test/test.sync.js b/test/test.sync.js deleted file mode 100644 index 56d7b23..0000000 --- a/test/test.sync.js +++ /dev/null @@ -1,83 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/sync.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - var fd = open( __filename ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - var fd = open( __filename, 'r+' ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - var fd = open( __filename, 'r+', 438 ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - var fd = open( 'beepboopbapbop' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+', 438 ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); From d3556a6cc275227535a543ee380a988cf5fb98fa Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Nov 2023 01:06:35 +0000 Subject: [PATCH 048/113] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index cfb2b75..d51b81e 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.1.1", @@ -81,4 +82,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 780476d34d88e0eeb807ef6fcbc87fded6b4931d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Nov 2023 04:58:17 +0000 Subject: [PATCH 049/113] Remove files --- index.d.ts | 150 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6332 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 eb67b7a..0000000 --- a/index.d.ts +++ /dev/null @@ -1,150 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Buffer } from 'buffer'; - -/** -* Callback invoked after opening a file. -* -* @param err - error argument -* @param fd - file descriptor -*/ -type Callback = ( err: Error, fd: number ) => void; - -/** -* Interface for opening a file. -*/ -interface Open { - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', 438, onOpen ); - */ - ( path: string | Buffer, flags: string | number, mode: number, clbk: Callback ): void; // tslint-disable-line max-line-length - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', onOpen ); - */ - ( path: string | Buffer, flags: string | number, clbk: Callback ): void; - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, onOpen ); - */ - ( path: string | Buffer, clbk: Callback ): void; - - /** - * Synchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @returns file descriptor or an error - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * var fd = open.sync( __filename, 'r+' ); - * if ( fd instanceof Error ) { - * throw fd; - * } - * closeSync( fd ); - */ - sync( path: string | Buffer, flags?: string | number, mode?: number ): number | Error; // tslint-disable-line max-line-length -} - -/** -* Asynchronously opens a file. -* -* @param path - file path -* @param flags - file system flags (default: 'r') -* @param mode - file mode (default: 0o666) -* @param clbk - callback to invoke after opening a file -* -* @example -* var closeSync = require( `@stdlib/fs/close` ).sync; -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( `@stdlib/fs/close` ).sync; -* -* var fd = open.sync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -declare var open: Open; - - -// EXPORTS // - -export = open; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d231c44..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/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){if(this instanceof e){var n=[null];n.push.apply(n,arguments);var r=Function.bind.apply(t,n);return new r}return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}var n=t(Object.freeze({__proto__:null,default:{}})),r="r",o=438,u=n.open;function i(e,t,n,i){var a=arguments.length;return 2===a?u(e,r,o,t):3===a?u(e,t,o,n):void u(e,t,n,i)}var a=n.openSync;function p(e,t,n){var u,i;u=arguments.length;try{i=1===u?a(e,r,o):a(e,t,2===u?o:n)}catch(e){return e}return i}e(i,"sync",p);export{i as default,p as sync}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 5fee640..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;iqBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAIzB,CAFC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 5445ce0..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From d33964b21c0bb0def4cbc09a0faa0285dccc1307 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Nov 2023 04:59:05 +0000 Subject: [PATCH 050/113] 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 | 53 +- benchmark/benchmark.js | 77 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 65 - docs/types/test.ts | 129 - examples/index.js | 56 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/defaults.json | 4 - lib/index.js | 63 - lib/main.js | 64 - lib/sync.js | 68 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 38 - test/test.main.js | 110 - test/test.sync.js | 83 - 46 files changed, 6211 insertions(+), 4110 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/defaults.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/sync.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.sync.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 8ec8ff6..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-11-01T00:42:55.214Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index a3a4470..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/fs/open) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 7617ad3..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/fs/open) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 664f5c5..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: '14 2 * * 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 + + ```
@@ -223,7 +222,7 @@ function onOpen( error, fd ) { ## 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]. @@ -287,11 +286,11 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close +[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close/tree/esm -[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists +[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists/tree/esm -[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file +[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 567aec3..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,77 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var closeSync = require( '@stdlib/fs-close' ).sync; -var pkg = require( './../package.json' ).name; -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return open( __filename, 'r+', done ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function done( error, fd ) { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - if ( error ) { - b.fail( error.message ); - } - next(); - } -}); - -bench( pkg+':sync', function benchmark( b ) { - var fd; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - fd = open.sync( __filename, 'r+' ); - if ( fd instanceof Error ) { - b.fail( fd.message ); - } else { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - } - } - b.toc(); - if ( fd instanceof Error ) { - b.fail( 'something went wrong' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index fa29fdf..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/fs/open" -%% click B href "https://github.com/stdlib-js/fs-open/tree/main" -%% click C href "https://github.com/stdlib-js/fs-open/tree/production" -%% click D href "https://github.com/stdlib-js/fs-open/tree/esm" -%% click E href "https://github.com/stdlib-js/fs-open/tree/deno" -%% click F href "https://github.com/stdlib-js/fs-open/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/fs/open -[production-url]: https://github.com/stdlib-js/fs-open/tree/production -[deno-url]: https://github.com/stdlib-js/fs-open/tree/deno -[umd-url]: https://github.com/stdlib-js/fs-open/tree/umd -[esm-url]: https://github.com/stdlib-js/fs-open/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 3e10601..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import open from '../docs/types/index'; -export = open; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 5358415..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var u=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var i=u(function(b,y){y.exports={flags:"r",mode:438}});var d=u(function(j,f){ -var a=require("fs").open,o=i();function p(r,e,t,s){var n=arguments.length;if(n===2)return a(r,o.flags,o.mode,e);if(n===3)return a(r,e,o.mode,t);a(r,e,t,s)}f.exports=p -});var m=u(function(k,l){ -var c=require("fs").openSync,v=i();function x(r,e,t){var s,n;s=arguments.length;try{s===1?n=c(r,v.flags,v.mode):s===2?n=c(r,e,v.mode):n=c(r,e,t)}catch(g){return g}return n}l.exports=x -});var S=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),q=d(),O=m();S(q,"sync",O);module.exports=q; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 65b6278..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/main.js", "../lib/sync.js", "../lib/index.js"], - "sourcesContent": ["{\n\t\"flags\": \"r\",\n\t\"mode\": 438\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var open = require( '@stdlib/fs-open' );\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nmodule.exports = open;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nmodule.exports = openSync;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var open = require( '@stdlib/fs-open' );\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var openSync = require( '@stdlib/fs-open' ).sync;\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar sync = require( './sync.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,CAAAA,EAAA,SACC,MAAS,IACT,KAAQ,GACT,ICHA,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAK,QAAS,IAAK,EAAE,KACrBC,EAAW,IA0Bf,SAASC,EAAMC,EAAMC,EAAOC,EAAMC,EAAO,CACxC,IAAIC,EAAQ,UAAU,OACtB,GAAKA,IAAU,EACd,OAAOP,EAAIG,EAAMF,EAAS,MAAOA,EAAS,KAAMG,CAAM,EAEvD,GAAKG,IAAU,EACd,OAAOP,EAAIG,EAAMC,EAAOH,EAAS,KAAMI,CAAK,EAE7CL,EAAIG,EAAMC,EAAOC,EAAMC,CAAK,CAC7B,CAKAP,EAAO,QAAUG,IC/DjB,IAAAM,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAO,QAAS,IAAK,EAAE,SACvBC,EAAW,IAsBf,SAASC,EAAUC,EAAMC,EAAOC,EAAO,CACtC,IAAIC,EACAC,EAEJD,EAAQ,UAAU,OAClB,GAAI,CACEA,IAAU,EACdC,EAAKP,EAAMG,EAAMF,EAAS,MAAOA,EAAS,IAAK,EACpCK,IAAU,EACrBC,EAAKP,EAAMG,EAAMC,EAAOH,EAAS,IAAK,EAEtCM,EAAKP,EAAMG,EAAMC,EAAOC,CAAK,CAE/B,OAAUG,EAAM,CACf,OAAOA,CACR,CACA,OAAOD,CACR,CAKAR,EAAO,QAAUG,ICjBjB,IAAIO,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAO,IAKXF,EAAaC,EAAM,OAAQC,CAAK,EAKhC,OAAO,QAAUD", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_main", "__commonJSMin", "exports", "module", "op", "defaults", "open", "path", "flags", "mode", "clbk", "nargs", "require_sync", "__commonJSMin", "exports", "module", "open", "defaults", "openSync", "path", "flags", "mode", "nargs", "fd", "err", "setReadOnly", "main", "sync"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4cbf7ac..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,65 +0,0 @@ - -{{alias}}( path[, flags[, mode]], clbk ) - Asynchronously opens a file. - - Some characters, such as <>:"/\|?*, are reserved under Windows. - Under NTFS, if the path contains a colon, Node.js will open a file system - stream. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - clbk: Function - Callback to invoke upon opening a file. - - Examples - -------- - > function onOpen( error, fd ) { - ... if ( error ) { - ... console.error( error.message ); - ... } else { - ... {{alias:@stdlib/fs/close}}.sync( fd ); - ... } - ... }; - > {{alias}}( './beep/boop.txt', onOpen ); - - -{{alias}}.sync( path[, flags[, mode]] ) - Synchronously opens a file. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - Returns - ------- - fd: Error|integer - File descriptor. - - Examples - -------- - > var fd = {{alias}}.sync( './beep/boop.txt' ); - > if ( !{{alias:@stdlib/assert/is-error}}( fd ) ) { {{alias:@stdlib/fs/close}}.sync( fd ); }; - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 67907a2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,129 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 open = require( './index' ); - -const done = ( error: Error, fd: number ) => { - if ( error || !fd ) { - throw error; - } -}; - - -// TESTS // - -// The function does not have a return value... -{ - open( '/path/to/beepboop', done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a string... -{ - open( 123, done ); // $ExpectError - open( false, done ); // $ExpectError - open( true, done ); // $ExpectError - open( null, done ); // $ExpectError - open( undefined, done ); // $ExpectError - open( [], done ); // $ExpectError - open( {}, done ); // $ExpectError - open( ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a last argument which is not a function with the expected signature... -{ - open( '/path/to/beepboop', 'abc' ); // $ExpectError - open( '/path/to/beepboop', 123 ); // $ExpectError - open( '/path/to/beepboop', false ); // $ExpectError - open( '/path/to/beepboop', true ); // $ExpectError - open( '/path/to/beepboop', null ); // $ExpectError - open( '/path/to/beepboop', undefined ); // $ExpectError - open( '/path/to/beepboop', [] ); // $ExpectError - open( '/path/to/beepboop', {} ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `flags` argument which is not a string or number... -{ - open( '/path/to/beepboop', false, done ); // $ExpectError - open( '/path/to/beepboop', true, done ); // $ExpectError - open( '/path/to/beepboop', null, done ); // $ExpectError - open( '/path/to/beepboop', undefined, done ); // $ExpectError - open( '/path/to/beepboop', [], done ); // $ExpectError - open( '/path/to/beepboop', {}, done ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` argument which is not a number... -{ - open( '/path/to/beepboop', 'r+', 'abc', done ); // $ExpectError - open( '/path/to/beepboop', 'r+', false, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', true, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', null, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', undefined, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', [], done ); // $ExpectError - open( '/path/to/beepboop', 'r+', {}, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - open(); // $ExpectError - open( 'C:\\foo\\bar\\baz' ); // $ExpectError -} - -// Attached to main export is a `sync` method which returns a number or an error... -{ - open.sync( '/path/to/beepboop' ); // $ExpectType number | Error -} - -// The compiler throws an error if the `sync` method is provided a first argument which is not a string... -{ - open.sync( 123 ); // $ExpectError - open.sync( false ); // $ExpectError - open.sync( true ); // $ExpectError - open.sync( null ); // $ExpectError - open.sync( undefined ); // $ExpectError - open.sync( [] ); // $ExpectError - open.sync( {} ); // $ExpectError - open.sync( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a second argument which is not a string or number... -{ - open.sync( '/path/to/beepboop', false ); // $ExpectError - open.sync( '/path/to/beepboop', true ); // $ExpectError - open.sync( '/path/to/beepboop', null ); // $ExpectError - open.sync( '/path/to/beepboop', [] ); // $ExpectError - open.sync( '/path/to/beepboop', {} ); // $ExpectError - open.sync( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a third argument which is not a number... -{ - open.sync( '/path/to/beepboop', 'r+', false ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', true ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', null ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', [] ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', {} ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided an unsupported number of arguments... -{ - open.sync(); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 71359fe..0000000 --- a/examples/index.js +++ /dev/null @@ -1,56 +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. -*/ - -'use strict'; - -var closeSync = require( '@stdlib/fs-close' ).sync; -var isError = require( '@stdlib/assert-is-error' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - -/* Sync */ - -var fd = open.sync( __filename, 'r+' ); -// returns - -console.log( isError( fd ) ); -// => false - -closeSync( fd ); - -fd = open.sync( 'beepboop' ); -// returns - -console.log( isError( fd ) ); -// => true - -/* Async */ - -open( __filename, onOpen ); -open( 'beepboop', onOpen ); - -function onOpen( error, fd ) { - if ( error ) { - if ( error.code === 'ENOENT' ) { - console.error( 'File does not exist.' ); - } else { - throw error; - } - } else { - closeSync( fd ); - } -} 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..d231c44 --- /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/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){if(this instanceof e){var n=[null];n.push.apply(n,arguments);var r=Function.bind.apply(t,n);return new r}return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}var n=t(Object.freeze({__proto__:null,default:{}})),r="r",o=438,u=n.open;function i(e,t,n,i){var a=arguments.length;return 2===a?u(e,r,o,t):3===a?u(e,t,o,n):void u(e,t,n,i)}var a=n.openSync;function p(e,t,n){var u,i;u=arguments.length;try{i=1===u?a(e,r,o):a(e,t,2===u?o:n)}catch(e){return e}return i}e(i,"sync",p);export{i as default,p as sync}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..5fee640 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;iqBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAIzB,CAFC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index cb174b7..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "flags": "r", - "mode": 438 -} diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 8edd6de..0000000 --- a/lib/index.js +++ /dev/null @@ -1,63 +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. -*/ - -'use strict'; - -/** -* Open a file. -* -* @module @stdlib/fs-open -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var openSync = require( '@stdlib/fs-open' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var sync = require( './sync.js' ); - - -// MAIN // - -setReadOnly( main, 'sync', sync ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index feb5171..0000000 --- a/lib/main.js +++ /dev/null @@ -1,64 +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. -*/ - -'use strict'; - -// MODULES // - -var op = require( 'fs' ).open; -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Asynchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @param {Function} clbk - callback to invoke after opening a file -* @returns {void} -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -*/ -function open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare - var nargs = arguments.length; - if ( nargs === 2 ) { - return op( path, defaults.flags, defaults.mode, flags ); - } - if ( nargs === 3 ) { - return op( path, flags, defaults.mode, mode ); - } - op( path, flags, mode, clbk ); -} - - -// EXPORTS // - -module.exports = open; diff --git a/lib/sync.js b/lib/sync.js deleted file mode 100644 index d8d2e00..0000000 --- a/lib/sync.js +++ /dev/null @@ -1,68 +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. -*/ - -'use strict'; - -// MODULES // - -var open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Synchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @returns {(integer|Error)} file descriptor or an error -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -function openSync( path, flags, mode ) { - var nargs; - var fd; - - nargs = arguments.length; - try { - if ( nargs === 1 ) { - fd = open( path, defaults.flags, defaults.mode ); - } else if ( nargs === 2 ) { - fd = open( path, flags, defaults.mode ); - } else { - fd = open( path, flags, mode ); - } - } catch ( err ) { - return err; - } - return fd; -} - - -// EXPORTS // - -module.exports = openSync; diff --git a/package.json b/package.json index d51b81e..337e340 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Open a file.", "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/utils-define-nonenumerable-read-only-property": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.1.1", - "@stdlib/assert-is-error": "^0.1.1", - "@stdlib/assert-is-nonnegative-integer": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/fs-close": "^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", "stdfs", @@ -82,4 +30,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..ed9552f --- /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 3c47135..0000000 --- a/test/test.js +++ /dev/null @@ -1,38 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is a function to open a file synchronously', function test( t ) { - t.equal( typeof open.sync, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 33b938f..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,110 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/main.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - open( __filename, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - open( __filename, 'r+', onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - open( __filename, 'r+', 438, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - open( 'beepboopbapbop', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', 438, onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); diff --git a/test/test.sync.js b/test/test.sync.js deleted file mode 100644 index 56d7b23..0000000 --- a/test/test.sync.js +++ /dev/null @@ -1,83 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/sync.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - var fd = open( __filename ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - var fd = open( __filename, 'r+' ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - var fd = open( __filename, 'r+', 438 ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - var fd = open( 'beepboopbapbop' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+', 438 ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); From ecc1ce48afa27900229bffa8d45fca2fb268a15f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 3 Nov 2023 14:23:04 +0000 Subject: [PATCH 051/113] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index cfb2b75..d51b81e 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.1.1", @@ -81,4 +82,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From b2515a7e6ac7837899c3914d697ff7fc109db82a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 3 Nov 2023 19:27:12 +0000 Subject: [PATCH 052/113] Remove files --- index.d.ts | 150 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6332 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 eb67b7a..0000000 --- a/index.d.ts +++ /dev/null @@ -1,150 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Buffer } from 'buffer'; - -/** -* Callback invoked after opening a file. -* -* @param err - error argument -* @param fd - file descriptor -*/ -type Callback = ( err: Error, fd: number ) => void; - -/** -* Interface for opening a file. -*/ -interface Open { - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', 438, onOpen ); - */ - ( path: string | Buffer, flags: string | number, mode: number, clbk: Callback ): void; // tslint-disable-line max-line-length - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', onOpen ); - */ - ( path: string | Buffer, flags: string | number, clbk: Callback ): void; - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, onOpen ); - */ - ( path: string | Buffer, clbk: Callback ): void; - - /** - * Synchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @returns file descriptor or an error - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * var fd = open.sync( __filename, 'r+' ); - * if ( fd instanceof Error ) { - * throw fd; - * } - * closeSync( fd ); - */ - sync( path: string | Buffer, flags?: string | number, mode?: number ): number | Error; // tslint-disable-line max-line-length -} - -/** -* Asynchronously opens a file. -* -* @param path - file path -* @param flags - file system flags (default: 'r') -* @param mode - file mode (default: 0o666) -* @param clbk - callback to invoke after opening a file -* -* @example -* var closeSync = require( `@stdlib/fs/close` ).sync; -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( `@stdlib/fs/close` ).sync; -* -* var fd = open.sync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -declare var open: Open; - - -// EXPORTS // - -export = open; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d231c44..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/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){if(this instanceof e){var n=[null];n.push.apply(n,arguments);var r=Function.bind.apply(t,n);return new r}return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}var n=t(Object.freeze({__proto__:null,default:{}})),r="r",o=438,u=n.open;function i(e,t,n,i){var a=arguments.length;return 2===a?u(e,r,o,t):3===a?u(e,t,o,n):void u(e,t,n,i)}var a=n.openSync;function p(e,t,n){var u,i;u=arguments.length;try{i=1===u?a(e,r,o):a(e,t,2===u?o:n)}catch(e){return e}return i}e(i,"sync",p);export{i as default,p as sync}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 5fee640..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;iqBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAIzB,CAFC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index ed9552f..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 9198b9b76f681a34d4bf6c6e3cc7ec9f25e7ab99 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 3 Nov 2023 19:27:51 +0000 Subject: [PATCH 053/113] 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 | 53 +- benchmark/benchmark.js | 77 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 65 - docs/types/test.ts | 129 - examples/index.js | 56 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/defaults.json | 4 - lib/index.js | 63 - lib/main.js | 64 - lib/sync.js | 68 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 38 - test/test.main.js | 110 - test/test.sync.js | 83 - 45 files changed, 6211 insertions(+), 4109 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/defaults.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/sync.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.sync.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 a3a4470..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/fs/open) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 7617ad3..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/fs/open) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 664f5c5..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: '14 2 * * 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 + + ```
@@ -223,7 +222,7 @@ function onOpen( error, fd ) { ## 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]. @@ -287,11 +286,11 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close +[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close/tree/esm -[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists +[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists/tree/esm -[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file +[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 567aec3..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,77 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var closeSync = require( '@stdlib/fs-close' ).sync; -var pkg = require( './../package.json' ).name; -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return open( __filename, 'r+', done ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function done( error, fd ) { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - if ( error ) { - b.fail( error.message ); - } - next(); - } -}); - -bench( pkg+':sync', function benchmark( b ) { - var fd; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - fd = open.sync( __filename, 'r+' ); - if ( fd instanceof Error ) { - b.fail( fd.message ); - } else { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - } - } - b.toc(); - if ( fd instanceof Error ) { - b.fail( 'something went wrong' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index fa29fdf..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/fs/open" -%% click B href "https://github.com/stdlib-js/fs-open/tree/main" -%% click C href "https://github.com/stdlib-js/fs-open/tree/production" -%% click D href "https://github.com/stdlib-js/fs-open/tree/esm" -%% click E href "https://github.com/stdlib-js/fs-open/tree/deno" -%% click F href "https://github.com/stdlib-js/fs-open/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/fs/open -[production-url]: https://github.com/stdlib-js/fs-open/tree/production -[deno-url]: https://github.com/stdlib-js/fs-open/tree/deno -[umd-url]: https://github.com/stdlib-js/fs-open/tree/umd -[esm-url]: https://github.com/stdlib-js/fs-open/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 3e10601..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import open from '../docs/types/index'; -export = open; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 5358415..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var u=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var i=u(function(b,y){y.exports={flags:"r",mode:438}});var d=u(function(j,f){ -var a=require("fs").open,o=i();function p(r,e,t,s){var n=arguments.length;if(n===2)return a(r,o.flags,o.mode,e);if(n===3)return a(r,e,o.mode,t);a(r,e,t,s)}f.exports=p -});var m=u(function(k,l){ -var c=require("fs").openSync,v=i();function x(r,e,t){var s,n;s=arguments.length;try{s===1?n=c(r,v.flags,v.mode):s===2?n=c(r,e,v.mode):n=c(r,e,t)}catch(g){return g}return n}l.exports=x -});var S=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),q=d(),O=m();S(q,"sync",O);module.exports=q; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 65b6278..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/main.js", "../lib/sync.js", "../lib/index.js"], - "sourcesContent": ["{\n\t\"flags\": \"r\",\n\t\"mode\": 438\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var open = require( '@stdlib/fs-open' );\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nmodule.exports = open;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nmodule.exports = openSync;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var open = require( '@stdlib/fs-open' );\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var openSync = require( '@stdlib/fs-open' ).sync;\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar sync = require( './sync.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,CAAAA,EAAA,SACC,MAAS,IACT,KAAQ,GACT,ICHA,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAK,QAAS,IAAK,EAAE,KACrBC,EAAW,IA0Bf,SAASC,EAAMC,EAAMC,EAAOC,EAAMC,EAAO,CACxC,IAAIC,EAAQ,UAAU,OACtB,GAAKA,IAAU,EACd,OAAOP,EAAIG,EAAMF,EAAS,MAAOA,EAAS,KAAMG,CAAM,EAEvD,GAAKG,IAAU,EACd,OAAOP,EAAIG,EAAMC,EAAOH,EAAS,KAAMI,CAAK,EAE7CL,EAAIG,EAAMC,EAAOC,EAAMC,CAAK,CAC7B,CAKAP,EAAO,QAAUG,IC/DjB,IAAAM,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAO,QAAS,IAAK,EAAE,SACvBC,EAAW,IAsBf,SAASC,EAAUC,EAAMC,EAAOC,EAAO,CACtC,IAAIC,EACAC,EAEJD,EAAQ,UAAU,OAClB,GAAI,CACEA,IAAU,EACdC,EAAKP,EAAMG,EAAMF,EAAS,MAAOA,EAAS,IAAK,EACpCK,IAAU,EACrBC,EAAKP,EAAMG,EAAMC,EAAOH,EAAS,IAAK,EAEtCM,EAAKP,EAAMG,EAAMC,EAAOC,CAAK,CAE/B,OAAUG,EAAM,CACf,OAAOA,CACR,CACA,OAAOD,CACR,CAKAR,EAAO,QAAUG,ICjBjB,IAAIO,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAO,IAKXF,EAAaC,EAAM,OAAQC,CAAK,EAKhC,OAAO,QAAUD", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_main", "__commonJSMin", "exports", "module", "op", "defaults", "open", "path", "flags", "mode", "clbk", "nargs", "require_sync", "__commonJSMin", "exports", "module", "open", "defaults", "openSync", "path", "flags", "mode", "nargs", "fd", "err", "setReadOnly", "main", "sync"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4cbf7ac..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,65 +0,0 @@ - -{{alias}}( path[, flags[, mode]], clbk ) - Asynchronously opens a file. - - Some characters, such as <>:"/\|?*, are reserved under Windows. - Under NTFS, if the path contains a colon, Node.js will open a file system - stream. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - clbk: Function - Callback to invoke upon opening a file. - - Examples - -------- - > function onOpen( error, fd ) { - ... if ( error ) { - ... console.error( error.message ); - ... } else { - ... {{alias:@stdlib/fs/close}}.sync( fd ); - ... } - ... }; - > {{alias}}( './beep/boop.txt', onOpen ); - - -{{alias}}.sync( path[, flags[, mode]] ) - Synchronously opens a file. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - Returns - ------- - fd: Error|integer - File descriptor. - - Examples - -------- - > var fd = {{alias}}.sync( './beep/boop.txt' ); - > if ( !{{alias:@stdlib/assert/is-error}}( fd ) ) { {{alias:@stdlib/fs/close}}.sync( fd ); }; - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 67907a2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,129 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 open = require( './index' ); - -const done = ( error: Error, fd: number ) => { - if ( error || !fd ) { - throw error; - } -}; - - -// TESTS // - -// The function does not have a return value... -{ - open( '/path/to/beepboop', done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a string... -{ - open( 123, done ); // $ExpectError - open( false, done ); // $ExpectError - open( true, done ); // $ExpectError - open( null, done ); // $ExpectError - open( undefined, done ); // $ExpectError - open( [], done ); // $ExpectError - open( {}, done ); // $ExpectError - open( ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a last argument which is not a function with the expected signature... -{ - open( '/path/to/beepboop', 'abc' ); // $ExpectError - open( '/path/to/beepboop', 123 ); // $ExpectError - open( '/path/to/beepboop', false ); // $ExpectError - open( '/path/to/beepboop', true ); // $ExpectError - open( '/path/to/beepboop', null ); // $ExpectError - open( '/path/to/beepboop', undefined ); // $ExpectError - open( '/path/to/beepboop', [] ); // $ExpectError - open( '/path/to/beepboop', {} ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `flags` argument which is not a string or number... -{ - open( '/path/to/beepboop', false, done ); // $ExpectError - open( '/path/to/beepboop', true, done ); // $ExpectError - open( '/path/to/beepboop', null, done ); // $ExpectError - open( '/path/to/beepboop', undefined, done ); // $ExpectError - open( '/path/to/beepboop', [], done ); // $ExpectError - open( '/path/to/beepboop', {}, done ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` argument which is not a number... -{ - open( '/path/to/beepboop', 'r+', 'abc', done ); // $ExpectError - open( '/path/to/beepboop', 'r+', false, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', true, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', null, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', undefined, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', [], done ); // $ExpectError - open( '/path/to/beepboop', 'r+', {}, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - open(); // $ExpectError - open( 'C:\\foo\\bar\\baz' ); // $ExpectError -} - -// Attached to main export is a `sync` method which returns a number or an error... -{ - open.sync( '/path/to/beepboop' ); // $ExpectType number | Error -} - -// The compiler throws an error if the `sync` method is provided a first argument which is not a string... -{ - open.sync( 123 ); // $ExpectError - open.sync( false ); // $ExpectError - open.sync( true ); // $ExpectError - open.sync( null ); // $ExpectError - open.sync( undefined ); // $ExpectError - open.sync( [] ); // $ExpectError - open.sync( {} ); // $ExpectError - open.sync( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a second argument which is not a string or number... -{ - open.sync( '/path/to/beepboop', false ); // $ExpectError - open.sync( '/path/to/beepboop', true ); // $ExpectError - open.sync( '/path/to/beepboop', null ); // $ExpectError - open.sync( '/path/to/beepboop', [] ); // $ExpectError - open.sync( '/path/to/beepboop', {} ); // $ExpectError - open.sync( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a third argument which is not a number... -{ - open.sync( '/path/to/beepboop', 'r+', false ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', true ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', null ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', [] ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', {} ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided an unsupported number of arguments... -{ - open.sync(); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 71359fe..0000000 --- a/examples/index.js +++ /dev/null @@ -1,56 +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. -*/ - -'use strict'; - -var closeSync = require( '@stdlib/fs-close' ).sync; -var isError = require( '@stdlib/assert-is-error' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - -/* Sync */ - -var fd = open.sync( __filename, 'r+' ); -// returns - -console.log( isError( fd ) ); -// => false - -closeSync( fd ); - -fd = open.sync( 'beepboop' ); -// returns - -console.log( isError( fd ) ); -// => true - -/* Async */ - -open( __filename, onOpen ); -open( 'beepboop', onOpen ); - -function onOpen( error, fd ) { - if ( error ) { - if ( error.code === 'ENOENT' ) { - console.error( 'File does not exist.' ); - } else { - throw error; - } - } else { - closeSync( fd ); - } -} 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..d231c44 --- /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/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){if(this instanceof e){var n=[null];n.push.apply(n,arguments);var r=Function.bind.apply(t,n);return new r}return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}var n=t(Object.freeze({__proto__:null,default:{}})),r="r",o=438,u=n.open;function i(e,t,n,i){var a=arguments.length;return 2===a?u(e,r,o,t):3===a?u(e,t,o,n):void u(e,t,n,i)}var a=n.openSync;function p(e,t,n){var u,i;u=arguments.length;try{i=1===u?a(e,r,o):a(e,t,2===u?o:n)}catch(e){return e}return i}e(i,"sync",p);export{i as default,p as sync}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..5fee640 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;iqBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAIzB,CAFC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index cb174b7..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "flags": "r", - "mode": 438 -} diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 8edd6de..0000000 --- a/lib/index.js +++ /dev/null @@ -1,63 +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. -*/ - -'use strict'; - -/** -* Open a file. -* -* @module @stdlib/fs-open -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var openSync = require( '@stdlib/fs-open' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var sync = require( './sync.js' ); - - -// MAIN // - -setReadOnly( main, 'sync', sync ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index feb5171..0000000 --- a/lib/main.js +++ /dev/null @@ -1,64 +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. -*/ - -'use strict'; - -// MODULES // - -var op = require( 'fs' ).open; -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Asynchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @param {Function} clbk - callback to invoke after opening a file -* @returns {void} -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -*/ -function open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare - var nargs = arguments.length; - if ( nargs === 2 ) { - return op( path, defaults.flags, defaults.mode, flags ); - } - if ( nargs === 3 ) { - return op( path, flags, defaults.mode, mode ); - } - op( path, flags, mode, clbk ); -} - - -// EXPORTS // - -module.exports = open; diff --git a/lib/sync.js b/lib/sync.js deleted file mode 100644 index d8d2e00..0000000 --- a/lib/sync.js +++ /dev/null @@ -1,68 +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. -*/ - -'use strict'; - -// MODULES // - -var open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Synchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @returns {(integer|Error)} file descriptor or an error -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -function openSync( path, flags, mode ) { - var nargs; - var fd; - - nargs = arguments.length; - try { - if ( nargs === 1 ) { - fd = open( path, defaults.flags, defaults.mode ); - } else if ( nargs === 2 ) { - fd = open( path, flags, defaults.mode ); - } else { - fd = open( path, flags, mode ); - } - } catch ( err ) { - return err; - } - return fd; -} - - -// EXPORTS // - -module.exports = openSync; diff --git a/package.json b/package.json index d51b81e..337e340 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Open a file.", "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/utils-define-nonenumerable-read-only-property": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.1.1", - "@stdlib/assert-is-error": "^0.1.1", - "@stdlib/assert-is-nonnegative-integer": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/fs-close": "^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", "stdfs", @@ -82,4 +30,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..8136dc8 --- /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 3c47135..0000000 --- a/test/test.js +++ /dev/null @@ -1,38 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is a function to open a file synchronously', function test( t ) { - t.equal( typeof open.sync, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 33b938f..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,110 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/main.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - open( __filename, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - open( __filename, 'r+', onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - open( __filename, 'r+', 438, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - open( 'beepboopbapbop', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', 438, onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); diff --git a/test/test.sync.js b/test/test.sync.js deleted file mode 100644 index 56d7b23..0000000 --- a/test/test.sync.js +++ /dev/null @@ -1,83 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/sync.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - var fd = open( __filename ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - var fd = open( __filename, 'r+' ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - var fd = open( __filename, 'r+', 438 ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - var fd = open( 'beepboopbapbop' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+', 438 ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); From f5a706409886cf46073c156f1caf90538afec953 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Dec 2023 01:04:13 +0000 Subject: [PATCH 054/113] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 7a37294..aedd665 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.1.1", @@ -81,4 +82,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 2fedd26ce0b170849dc04a50fd16cad83d519fee Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Dec 2023 04:05:01 +0000 Subject: [PATCH 055/113] Remove files --- index.d.ts | 150 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6332 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 d52ee22..0000000 --- a/index.d.ts +++ /dev/null @@ -1,150 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Buffer } from 'buffer'; - -/** -* Callback invoked after opening a file. -* -* @param err - error argument -* @param fd - file descriptor -*/ -type Callback = ( err: Error, fd: number ) => void; - -/** -* Interface for opening a file. -*/ -interface Open { - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', 438, onOpen ); - */ - ( path: string | Buffer, flags: string | number, mode: number, clbk: Callback ): void; - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', onOpen ); - */ - ( path: string | Buffer, flags: string | number, clbk: Callback ): void; - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, onOpen ); - */ - ( path: string | Buffer, clbk: Callback ): void; - - /** - * Synchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @returns file descriptor or an error - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * var fd = open.sync( __filename, 'r+' ); - * if ( fd instanceof Error ) { - * throw fd; - * } - * closeSync( fd ); - */ - sync( path: string | Buffer, flags?: string | number, mode?: number ): number | Error; -} - -/** -* Asynchronously opens a file. -* -* @param path - file path -* @param flags - file system flags (default: 'r') -* @param mode - file mode (default: 0o666) -* @param clbk - callback to invoke after opening a file -* -* @example -* var closeSync = require( `@stdlib/fs/close` ).sync; -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( `@stdlib/fs/close` ).sync; -* -* var fd = open.sync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -declare var open: Open; - - -// EXPORTS // - -export = open; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d231c44..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/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){if(this instanceof e){var n=[null];n.push.apply(n,arguments);var r=Function.bind.apply(t,n);return new r}return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}var n=t(Object.freeze({__proto__:null,default:{}})),r="r",o=438,u=n.open;function i(e,t,n,i){var a=arguments.length;return 2===a?u(e,r,o,t):3===a?u(e,t,o,n):void u(e,t,n,i)}var a=n.openSync;function p(e,t,n){var u,i;u=arguments.length;try{i=1===u?a(e,r,o):a(e,t,2===u?o:n)}catch(e){return e}return i}e(i,"sync",p);export{i as default,p as sync}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 5fee640..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;iqBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAIzB,CAFC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 8136dc8..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 684047eb61508e20cee41b51692ba8ebc21eb056 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Dec 2023 04:05:36 +0000 Subject: [PATCH 056/113] 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 | 53 +- benchmark/benchmark.js | 77 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 65 - docs/types/test.ts | 129 - examples/index.js | 56 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/defaults.json | 4 - lib/index.js | 63 - lib/main.js | 64 - lib/sync.js | 68 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 38 - test/test.main.js | 110 - test/test.sync.js | 83 - 46 files changed, 6211 insertions(+), 4105 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/defaults.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/sync.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.sync.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 bfd9bbc..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-12-01T00:46:05.644Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index a3a4470..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/fs/open) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 7617ad3..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/fs/open) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 664f5c5..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: '14 2 * * 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 + + ```
@@ -223,7 +222,7 @@ function onOpen( error, fd ) { ## 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]. @@ -287,11 +286,11 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. -[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close +[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close/tree/esm -[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists +[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists/tree/esm -[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file +[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 567aec3..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,77 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var closeSync = require( '@stdlib/fs-close' ).sync; -var pkg = require( './../package.json' ).name; -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return open( __filename, 'r+', done ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function done( error, fd ) { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - if ( error ) { - b.fail( error.message ); - } - next(); - } -}); - -bench( pkg+':sync', function benchmark( b ) { - var fd; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - fd = open.sync( __filename, 'r+' ); - if ( fd instanceof Error ) { - b.fail( fd.message ); - } else { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - } - } - b.toc(); - if ( fd instanceof Error ) { - b.fail( 'something went wrong' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index fa29fdf..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/fs/open" -%% click B href "https://github.com/stdlib-js/fs-open/tree/main" -%% click C href "https://github.com/stdlib-js/fs-open/tree/production" -%% click D href "https://github.com/stdlib-js/fs-open/tree/esm" -%% click E href "https://github.com/stdlib-js/fs-open/tree/deno" -%% click F href "https://github.com/stdlib-js/fs-open/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/fs/open -[production-url]: https://github.com/stdlib-js/fs-open/tree/production -[deno-url]: https://github.com/stdlib-js/fs-open/tree/deno -[umd-url]: https://github.com/stdlib-js/fs-open/tree/umd -[esm-url]: https://github.com/stdlib-js/fs-open/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 3e10601..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import open from '../docs/types/index'; -export = open; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 5358415..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var u=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var i=u(function(b,y){y.exports={flags:"r",mode:438}});var d=u(function(j,f){ -var a=require("fs").open,o=i();function p(r,e,t,s){var n=arguments.length;if(n===2)return a(r,o.flags,o.mode,e);if(n===3)return a(r,e,o.mode,t);a(r,e,t,s)}f.exports=p -});var m=u(function(k,l){ -var c=require("fs").openSync,v=i();function x(r,e,t){var s,n;s=arguments.length;try{s===1?n=c(r,v.flags,v.mode):s===2?n=c(r,e,v.mode):n=c(r,e,t)}catch(g){return g}return n}l.exports=x -});var S=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),q=d(),O=m();S(q,"sync",O);module.exports=q; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 65b6278..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/main.js", "../lib/sync.js", "../lib/index.js"], - "sourcesContent": ["{\n\t\"flags\": \"r\",\n\t\"mode\": 438\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var open = require( '@stdlib/fs-open' );\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nmodule.exports = open;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nmodule.exports = openSync;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var open = require( '@stdlib/fs-open' );\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var openSync = require( '@stdlib/fs-open' ).sync;\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar sync = require( './sync.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,CAAAA,EAAA,SACC,MAAS,IACT,KAAQ,GACT,ICHA,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAK,QAAS,IAAK,EAAE,KACrBC,EAAW,IA0Bf,SAASC,EAAMC,EAAMC,EAAOC,EAAMC,EAAO,CACxC,IAAIC,EAAQ,UAAU,OACtB,GAAKA,IAAU,EACd,OAAOP,EAAIG,EAAMF,EAAS,MAAOA,EAAS,KAAMG,CAAM,EAEvD,GAAKG,IAAU,EACd,OAAOP,EAAIG,EAAMC,EAAOH,EAAS,KAAMI,CAAK,EAE7CL,EAAIG,EAAMC,EAAOC,EAAMC,CAAK,CAC7B,CAKAP,EAAO,QAAUG,IC/DjB,IAAAM,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAO,QAAS,IAAK,EAAE,SACvBC,EAAW,IAsBf,SAASC,EAAUC,EAAMC,EAAOC,EAAO,CACtC,IAAIC,EACAC,EAEJD,EAAQ,UAAU,OAClB,GAAI,CACEA,IAAU,EACdC,EAAKP,EAAMG,EAAMF,EAAS,MAAOA,EAAS,IAAK,EACpCK,IAAU,EACrBC,EAAKP,EAAMG,EAAMC,EAAOH,EAAS,IAAK,EAEtCM,EAAKP,EAAMG,EAAMC,EAAOC,CAAK,CAE/B,OAAUG,EAAM,CACf,OAAOA,CACR,CACA,OAAOD,CACR,CAKAR,EAAO,QAAUG,ICjBjB,IAAIO,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAO,IAKXF,EAAaC,EAAM,OAAQC,CAAK,EAKhC,OAAO,QAAUD", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_main", "__commonJSMin", "exports", "module", "op", "defaults", "open", "path", "flags", "mode", "clbk", "nargs", "require_sync", "__commonJSMin", "exports", "module", "open", "defaults", "openSync", "path", "flags", "mode", "nargs", "fd", "err", "setReadOnly", "main", "sync"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4cbf7ac..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,65 +0,0 @@ - -{{alias}}( path[, flags[, mode]], clbk ) - Asynchronously opens a file. - - Some characters, such as <>:"/\|?*, are reserved under Windows. - Under NTFS, if the path contains a colon, Node.js will open a file system - stream. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - clbk: Function - Callback to invoke upon opening a file. - - Examples - -------- - > function onOpen( error, fd ) { - ... if ( error ) { - ... console.error( error.message ); - ... } else { - ... {{alias:@stdlib/fs/close}}.sync( fd ); - ... } - ... }; - > {{alias}}( './beep/boop.txt', onOpen ); - - -{{alias}}.sync( path[, flags[, mode]] ) - Synchronously opens a file. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - Returns - ------- - fd: Error|integer - File descriptor. - - Examples - -------- - > var fd = {{alias}}.sync( './beep/boop.txt' ); - > if ( !{{alias:@stdlib/assert/is-error}}( fd ) ) { {{alias:@stdlib/fs/close}}.sync( fd ); }; - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 67907a2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,129 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 open = require( './index' ); - -const done = ( error: Error, fd: number ) => { - if ( error || !fd ) { - throw error; - } -}; - - -// TESTS // - -// The function does not have a return value... -{ - open( '/path/to/beepboop', done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a string... -{ - open( 123, done ); // $ExpectError - open( false, done ); // $ExpectError - open( true, done ); // $ExpectError - open( null, done ); // $ExpectError - open( undefined, done ); // $ExpectError - open( [], done ); // $ExpectError - open( {}, done ); // $ExpectError - open( ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a last argument which is not a function with the expected signature... -{ - open( '/path/to/beepboop', 'abc' ); // $ExpectError - open( '/path/to/beepboop', 123 ); // $ExpectError - open( '/path/to/beepboop', false ); // $ExpectError - open( '/path/to/beepboop', true ); // $ExpectError - open( '/path/to/beepboop', null ); // $ExpectError - open( '/path/to/beepboop', undefined ); // $ExpectError - open( '/path/to/beepboop', [] ); // $ExpectError - open( '/path/to/beepboop', {} ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `flags` argument which is not a string or number... -{ - open( '/path/to/beepboop', false, done ); // $ExpectError - open( '/path/to/beepboop', true, done ); // $ExpectError - open( '/path/to/beepboop', null, done ); // $ExpectError - open( '/path/to/beepboop', undefined, done ); // $ExpectError - open( '/path/to/beepboop', [], done ); // $ExpectError - open( '/path/to/beepboop', {}, done ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` argument which is not a number... -{ - open( '/path/to/beepboop', 'r+', 'abc', done ); // $ExpectError - open( '/path/to/beepboop', 'r+', false, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', true, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', null, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', undefined, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', [], done ); // $ExpectError - open( '/path/to/beepboop', 'r+', {}, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - open(); // $ExpectError - open( 'C:\\foo\\bar\\baz' ); // $ExpectError -} - -// Attached to main export is a `sync` method which returns a number or an error... -{ - open.sync( '/path/to/beepboop' ); // $ExpectType number | Error -} - -// The compiler throws an error if the `sync` method is provided a first argument which is not a string... -{ - open.sync( 123 ); // $ExpectError - open.sync( false ); // $ExpectError - open.sync( true ); // $ExpectError - open.sync( null ); // $ExpectError - open.sync( undefined ); // $ExpectError - open.sync( [] ); // $ExpectError - open.sync( {} ); // $ExpectError - open.sync( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a second argument which is not a string or number... -{ - open.sync( '/path/to/beepboop', false ); // $ExpectError - open.sync( '/path/to/beepboop', true ); // $ExpectError - open.sync( '/path/to/beepboop', null ); // $ExpectError - open.sync( '/path/to/beepboop', [] ); // $ExpectError - open.sync( '/path/to/beepboop', {} ); // $ExpectError - open.sync( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a third argument which is not a number... -{ - open.sync( '/path/to/beepboop', 'r+', false ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', true ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', null ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', [] ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', {} ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided an unsupported number of arguments... -{ - open.sync(); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 71359fe..0000000 --- a/examples/index.js +++ /dev/null @@ -1,56 +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. -*/ - -'use strict'; - -var closeSync = require( '@stdlib/fs-close' ).sync; -var isError = require( '@stdlib/assert-is-error' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - -/* Sync */ - -var fd = open.sync( __filename, 'r+' ); -// returns - -console.log( isError( fd ) ); -// => false - -closeSync( fd ); - -fd = open.sync( 'beepboop' ); -// returns - -console.log( isError( fd ) ); -// => true - -/* Async */ - -open( __filename, onOpen ); -open( 'beepboop', onOpen ); - -function onOpen( error, fd ) { - if ( error ) { - if ( error.code === 'ENOENT' ) { - console.error( 'File does not exist.' ); - } else { - throw error; - } - } else { - closeSync( fd ); - } -} 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..d231c44 --- /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/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){if(this instanceof e){var n=[null];n.push.apply(n,arguments);var r=Function.bind.apply(t,n);return new r}return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}var n=t(Object.freeze({__proto__:null,default:{}})),r="r",o=438,u=n.open;function i(e,t,n,i){var a=arguments.length;return 2===a?u(e,r,o,t):3===a?u(e,t,o,n):void u(e,t,n,i)}var a=n.openSync;function p(e,t,n){var u,i;u=arguments.length;try{i=1===u?a(e,r,o):a(e,t,2===u?o:n)}catch(e){return e}return i}e(i,"sync",p);export{i as default,p as sync}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..5fee640 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;iqBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAIzB,CAFC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index cb174b7..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "flags": "r", - "mode": 438 -} diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 8edd6de..0000000 --- a/lib/index.js +++ /dev/null @@ -1,63 +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. -*/ - -'use strict'; - -/** -* Open a file. -* -* @module @stdlib/fs-open -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var openSync = require( '@stdlib/fs-open' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var sync = require( './sync.js' ); - - -// MAIN // - -setReadOnly( main, 'sync', sync ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index feb5171..0000000 --- a/lib/main.js +++ /dev/null @@ -1,64 +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. -*/ - -'use strict'; - -// MODULES // - -var op = require( 'fs' ).open; -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Asynchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @param {Function} clbk - callback to invoke after opening a file -* @returns {void} -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -*/ -function open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare - var nargs = arguments.length; - if ( nargs === 2 ) { - return op( path, defaults.flags, defaults.mode, flags ); - } - if ( nargs === 3 ) { - return op( path, flags, defaults.mode, mode ); - } - op( path, flags, mode, clbk ); -} - - -// EXPORTS // - -module.exports = open; diff --git a/lib/sync.js b/lib/sync.js deleted file mode 100644 index d8d2e00..0000000 --- a/lib/sync.js +++ /dev/null @@ -1,68 +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. -*/ - -'use strict'; - -// MODULES // - -var open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Synchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @returns {(integer|Error)} file descriptor or an error -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -function openSync( path, flags, mode ) { - var nargs; - var fd; - - nargs = arguments.length; - try { - if ( nargs === 1 ) { - fd = open( path, defaults.flags, defaults.mode ); - } else if ( nargs === 2 ) { - fd = open( path, flags, defaults.mode ); - } else { - fd = open( path, flags, mode ); - } - } catch ( err ) { - return err; - } - return fd; -} - - -// EXPORTS // - -module.exports = openSync; diff --git a/package.json b/package.json index aedd665..337e340 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Open a file.", "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/utils-define-nonenumerable-read-only-property": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.1.1", - "@stdlib/assert-is-error": "^0.1.1", - "@stdlib/assert-is-nonnegative-integer": "^0.1.0", - "@stdlib/bench": "^0.2.1", - "@stdlib/fs-close": "^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", "stdfs", @@ -82,4 +30,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..e2282d0 --- /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 3c47135..0000000 --- a/test/test.js +++ /dev/null @@ -1,38 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is a function to open a file synchronously', function test( t ) { - t.equal( typeof open.sync, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 33b938f..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,110 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/main.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - open( __filename, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - open( __filename, 'r+', onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - open( __filename, 'r+', 438, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - open( 'beepboopbapbop', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', 438, onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); diff --git a/test/test.sync.js b/test/test.sync.js deleted file mode 100644 index 56d7b23..0000000 --- a/test/test.sync.js +++ /dev/null @@ -1,83 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/sync.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - var fd = open( __filename ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - var fd = open( __filename, 'r+' ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - var fd = open( __filename, 'r+', 438 ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - var fd = open( 'beepboopbapbop' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+', 438 ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); From 133bf423020fdd2ed9765ec2f040c16b15b0fdd2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 00:59:13 +0000 Subject: [PATCH 057/113] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 07ecece..a79ef46 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.1.1", @@ -81,4 +82,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 1d548c31557e263300c6b27b94896ba37a66a303 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 02:23:17 +0000 Subject: [PATCH 058/113] Remove files --- index.d.ts | 150 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6332 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 d52ee22..0000000 --- a/index.d.ts +++ /dev/null @@ -1,150 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Buffer } from 'buffer'; - -/** -* Callback invoked after opening a file. -* -* @param err - error argument -* @param fd - file descriptor -*/ -type Callback = ( err: Error, fd: number ) => void; - -/** -* Interface for opening a file. -*/ -interface Open { - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', 438, onOpen ); - */ - ( path: string | Buffer, flags: string | number, mode: number, clbk: Callback ): void; - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', onOpen ); - */ - ( path: string | Buffer, flags: string | number, clbk: Callback ): void; - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, onOpen ); - */ - ( path: string | Buffer, clbk: Callback ): void; - - /** - * Synchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @returns file descriptor or an error - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * var fd = open.sync( __filename, 'r+' ); - * if ( fd instanceof Error ) { - * throw fd; - * } - * closeSync( fd ); - */ - sync( path: string | Buffer, flags?: string | number, mode?: number ): number | Error; -} - -/** -* Asynchronously opens a file. -* -* @param path - file path -* @param flags - file system flags (default: 'r') -* @param mode - file mode (default: 0o666) -* @param clbk - callback to invoke after opening a file -* -* @example -* var closeSync = require( `@stdlib/fs/close` ).sync; -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( `@stdlib/fs/close` ).sync; -* -* var fd = open.sync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -declare var open: Open; - - -// EXPORTS // - -export = open; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index d231c44..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/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){if(this instanceof e){var n=[null];n.push.apply(n,arguments);var r=Function.bind.apply(t,n);return new r}return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}var n=t(Object.freeze({__proto__:null,default:{}})),r="r",o=438,u=n.open;function i(e,t,n,i){var a=arguments.length;return 2===a?u(e,r,o,t):3===a?u(e,t,o,n):void u(e,t,n,i)}var a=n.openSync;function p(e,t,n){var u,i;u=arguments.length;try{i=1===u?a(e,r,o):a(e,t,2===u?o:n)}catch(e){return e}return i}e(i,"sync",p);export{i as default,p as sync}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 5fee640..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;iqBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAIzB,CAFC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index e2282d0..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 641d6167609bbef70a47111053e34073940d5a59 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 02:23:29 +0000 Subject: [PATCH 059/113] 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 | 53 +- SECURITY.md | 5 - benchmark/benchmark.js | 77 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 65 - docs/types/test.ts | 129 - examples/index.js | 56 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/defaults.json | 4 - lib/index.js | 63 - lib/main.js | 64 - lib/sync.js | 68 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 38 - test/test.main.js | 110 - test/test.sync.js | 83 - 47 files changed, 6211 insertions(+), 4111 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/defaults.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/sync.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.sync.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 9ccbefe..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-01-01T00:44:48.469Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index a3a4470..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/fs/open) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 7617ad3..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/fs/open) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 5865b49..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: '14 2 * * 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 + + ```
@@ -223,7 +222,7 @@ function onOpen( error, fd ) { ## 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]. @@ -287,11 +286,11 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close +[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close/tree/esm -[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists +[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists/tree/esm -[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file +[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file/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 503cc81..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,77 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var closeSync = require( '@stdlib/fs-close' ).sync; -var pkg = require( './../package.json' ).name; -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return open( __filename, 'r+', done ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function done( error, fd ) { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - if ( error ) { - b.fail( error.message ); - } - next(); - } -}); - -bench( pkg+':sync', function benchmark( b ) { - var fd; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - fd = open.sync( __filename, 'r+' ); - if ( fd instanceof Error ) { - b.fail( fd.message ); - } else { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - } - } - b.toc(); - if ( fd instanceof Error ) { - b.fail( 'something went wrong' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index fa29fdf..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/fs/open" -%% click B href "https://github.com/stdlib-js/fs-open/tree/main" -%% click C href "https://github.com/stdlib-js/fs-open/tree/production" -%% click D href "https://github.com/stdlib-js/fs-open/tree/esm" -%% click E href "https://github.com/stdlib-js/fs-open/tree/deno" -%% click F href "https://github.com/stdlib-js/fs-open/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/fs/open -[production-url]: https://github.com/stdlib-js/fs-open/tree/production -[deno-url]: https://github.com/stdlib-js/fs-open/tree/deno -[umd-url]: https://github.com/stdlib-js/fs-open/tree/umd -[esm-url]: https://github.com/stdlib-js/fs-open/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 3e10601..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import open from '../docs/types/index'; -export = open; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 5358415..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var u=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var i=u(function(b,y){y.exports={flags:"r",mode:438}});var d=u(function(j,f){ -var a=require("fs").open,o=i();function p(r,e,t,s){var n=arguments.length;if(n===2)return a(r,o.flags,o.mode,e);if(n===3)return a(r,e,o.mode,t);a(r,e,t,s)}f.exports=p -});var m=u(function(k,l){ -var c=require("fs").openSync,v=i();function x(r,e,t){var s,n;s=arguments.length;try{s===1?n=c(r,v.flags,v.mode):s===2?n=c(r,e,v.mode):n=c(r,e,t)}catch(g){return g}return n}l.exports=x -});var S=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),q=d(),O=m();S(q,"sync",O);module.exports=q; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 65b6278..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/main.js", "../lib/sync.js", "../lib/index.js"], - "sourcesContent": ["{\n\t\"flags\": \"r\",\n\t\"mode\": 438\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var open = require( '@stdlib/fs-open' );\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nmodule.exports = open;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nmodule.exports = openSync;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var open = require( '@stdlib/fs-open' );\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var openSync = require( '@stdlib/fs-open' ).sync;\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar sync = require( './sync.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,CAAAA,EAAA,SACC,MAAS,IACT,KAAQ,GACT,ICHA,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAK,QAAS,IAAK,EAAE,KACrBC,EAAW,IA0Bf,SAASC,EAAMC,EAAMC,EAAOC,EAAMC,EAAO,CACxC,IAAIC,EAAQ,UAAU,OACtB,GAAKA,IAAU,EACd,OAAOP,EAAIG,EAAMF,EAAS,MAAOA,EAAS,KAAMG,CAAM,EAEvD,GAAKG,IAAU,EACd,OAAOP,EAAIG,EAAMC,EAAOH,EAAS,KAAMI,CAAK,EAE7CL,EAAIG,EAAMC,EAAOC,EAAMC,CAAK,CAC7B,CAKAP,EAAO,QAAUG,IC/DjB,IAAAM,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAO,QAAS,IAAK,EAAE,SACvBC,EAAW,IAsBf,SAASC,EAAUC,EAAMC,EAAOC,EAAO,CACtC,IAAIC,EACAC,EAEJD,EAAQ,UAAU,OAClB,GAAI,CACEA,IAAU,EACdC,EAAKP,EAAMG,EAAMF,EAAS,MAAOA,EAAS,IAAK,EACpCK,IAAU,EACrBC,EAAKP,EAAMG,EAAMC,EAAOH,EAAS,IAAK,EAEtCM,EAAKP,EAAMG,EAAMC,EAAOC,CAAK,CAE/B,OAAUG,EAAM,CACf,OAAOA,CACR,CACA,OAAOD,CACR,CAKAR,EAAO,QAAUG,ICjBjB,IAAIO,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAO,IAKXF,EAAaC,EAAM,OAAQC,CAAK,EAKhC,OAAO,QAAUD", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_main", "__commonJSMin", "exports", "module", "op", "defaults", "open", "path", "flags", "mode", "clbk", "nargs", "require_sync", "__commonJSMin", "exports", "module", "open", "defaults", "openSync", "path", "flags", "mode", "nargs", "fd", "err", "setReadOnly", "main", "sync"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4cbf7ac..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,65 +0,0 @@ - -{{alias}}( path[, flags[, mode]], clbk ) - Asynchronously opens a file. - - Some characters, such as <>:"/\|?*, are reserved under Windows. - Under NTFS, if the path contains a colon, Node.js will open a file system - stream. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - clbk: Function - Callback to invoke upon opening a file. - - Examples - -------- - > function onOpen( error, fd ) { - ... if ( error ) { - ... console.error( error.message ); - ... } else { - ... {{alias:@stdlib/fs/close}}.sync( fd ); - ... } - ... }; - > {{alias}}( './beep/boop.txt', onOpen ); - - -{{alias}}.sync( path[, flags[, mode]] ) - Synchronously opens a file. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - Returns - ------- - fd: Error|integer - File descriptor. - - Examples - -------- - > var fd = {{alias}}.sync( './beep/boop.txt' ); - > if ( !{{alias:@stdlib/assert/is-error}}( fd ) ) { {{alias:@stdlib/fs/close}}.sync( fd ); }; - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 67907a2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,129 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 open = require( './index' ); - -const done = ( error: Error, fd: number ) => { - if ( error || !fd ) { - throw error; - } -}; - - -// TESTS // - -// The function does not have a return value... -{ - open( '/path/to/beepboop', done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a string... -{ - open( 123, done ); // $ExpectError - open( false, done ); // $ExpectError - open( true, done ); // $ExpectError - open( null, done ); // $ExpectError - open( undefined, done ); // $ExpectError - open( [], done ); // $ExpectError - open( {}, done ); // $ExpectError - open( ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a last argument which is not a function with the expected signature... -{ - open( '/path/to/beepboop', 'abc' ); // $ExpectError - open( '/path/to/beepboop', 123 ); // $ExpectError - open( '/path/to/beepboop', false ); // $ExpectError - open( '/path/to/beepboop', true ); // $ExpectError - open( '/path/to/beepboop', null ); // $ExpectError - open( '/path/to/beepboop', undefined ); // $ExpectError - open( '/path/to/beepboop', [] ); // $ExpectError - open( '/path/to/beepboop', {} ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `flags` argument which is not a string or number... -{ - open( '/path/to/beepboop', false, done ); // $ExpectError - open( '/path/to/beepboop', true, done ); // $ExpectError - open( '/path/to/beepboop', null, done ); // $ExpectError - open( '/path/to/beepboop', undefined, done ); // $ExpectError - open( '/path/to/beepboop', [], done ); // $ExpectError - open( '/path/to/beepboop', {}, done ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` argument which is not a number... -{ - open( '/path/to/beepboop', 'r+', 'abc', done ); // $ExpectError - open( '/path/to/beepboop', 'r+', false, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', true, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', null, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', undefined, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', [], done ); // $ExpectError - open( '/path/to/beepboop', 'r+', {}, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - open(); // $ExpectError - open( 'C:\\foo\\bar\\baz' ); // $ExpectError -} - -// Attached to main export is a `sync` method which returns a number or an error... -{ - open.sync( '/path/to/beepboop' ); // $ExpectType number | Error -} - -// The compiler throws an error if the `sync` method is provided a first argument which is not a string... -{ - open.sync( 123 ); // $ExpectError - open.sync( false ); // $ExpectError - open.sync( true ); // $ExpectError - open.sync( null ); // $ExpectError - open.sync( undefined ); // $ExpectError - open.sync( [] ); // $ExpectError - open.sync( {} ); // $ExpectError - open.sync( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a second argument which is not a string or number... -{ - open.sync( '/path/to/beepboop', false ); // $ExpectError - open.sync( '/path/to/beepboop', true ); // $ExpectError - open.sync( '/path/to/beepboop', null ); // $ExpectError - open.sync( '/path/to/beepboop', [] ); // $ExpectError - open.sync( '/path/to/beepboop', {} ); // $ExpectError - open.sync( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a third argument which is not a number... -{ - open.sync( '/path/to/beepboop', 'r+', false ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', true ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', null ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', [] ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', {} ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided an unsupported number of arguments... -{ - open.sync(); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 71359fe..0000000 --- a/examples/index.js +++ /dev/null @@ -1,56 +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. -*/ - -'use strict'; - -var closeSync = require( '@stdlib/fs-close' ).sync; -var isError = require( '@stdlib/assert-is-error' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - -/* Sync */ - -var fd = open.sync( __filename, 'r+' ); -// returns - -console.log( isError( fd ) ); -// => false - -closeSync( fd ); - -fd = open.sync( 'beepboop' ); -// returns - -console.log( isError( fd ) ); -// => true - -/* Async */ - -open( __filename, onOpen ); -open( 'beepboop', onOpen ); - -function onOpen( error, fd ) { - if ( error ) { - if ( error.code === 'ENOENT' ) { - console.error( 'File does not exist.' ); - } else { - throw error; - } - } else { - closeSync( fd ); - } -} 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..e60667a --- /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/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){if(this instanceof e){var n=[null];n.push.apply(n,arguments);var r=Function.bind.apply(t,n);return new r}return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}var n=t(Object.freeze({__proto__:null,default:{}})),r="r",o=438,u=n.open;function i(e,t,n,i){var a=arguments.length;return 2===a?u(e,r,o,t):3===a?u(e,t,o,n):void u(e,t,n,i)}var a=n.openSync;function p(e,t,n){var u,i;u=arguments.length;try{i=1===u?a(e,r,o):a(e,t,2===u?o:n)}catch(e){return e}return i}e(i,"sync",p);export{i as default,p as sync}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..5fee640 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;iqBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAIzB,CAFC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index cb174b7..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "flags": "r", - "mode": 438 -} diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 8edd6de..0000000 --- a/lib/index.js +++ /dev/null @@ -1,63 +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. -*/ - -'use strict'; - -/** -* Open a file. -* -* @module @stdlib/fs-open -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var openSync = require( '@stdlib/fs-open' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var sync = require( './sync.js' ); - - -// MAIN // - -setReadOnly( main, 'sync', sync ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index feb5171..0000000 --- a/lib/main.js +++ /dev/null @@ -1,64 +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. -*/ - -'use strict'; - -// MODULES // - -var op = require( 'fs' ).open; -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Asynchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @param {Function} clbk - callback to invoke after opening a file -* @returns {void} -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -*/ -function open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare - var nargs = arguments.length; - if ( nargs === 2 ) { - return op( path, defaults.flags, defaults.mode, flags ); - } - if ( nargs === 3 ) { - return op( path, flags, defaults.mode, mode ); - } - op( path, flags, mode, clbk ); -} - - -// EXPORTS // - -module.exports = open; diff --git a/lib/sync.js b/lib/sync.js deleted file mode 100644 index d8d2e00..0000000 --- a/lib/sync.js +++ /dev/null @@ -1,68 +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. -*/ - -'use strict'; - -// MODULES // - -var open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Synchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @returns {(integer|Error)} file descriptor or an error -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -function openSync( path, flags, mode ) { - var nargs; - var fd; - - nargs = arguments.length; - try { - if ( nargs === 1 ) { - fd = open( path, defaults.flags, defaults.mode ); - } else if ( nargs === 2 ) { - fd = open( path, flags, defaults.mode ); - } else { - fd = open( path, flags, mode ); - } - } catch ( err ) { - return err; - } - return fd; -} - - -// EXPORTS // - -module.exports = openSync; diff --git a/package.json b/package.json index a79ef46..337e340 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Open a file.", "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/utils-define-nonenumerable-read-only-property": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.1.1", - "@stdlib/assert-is-error": "^0.1.1", - "@stdlib/assert-is-nonnegative-integer": "^0.1.0", - "@stdlib/fs-close": "^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", "stdfs", @@ -82,4 +30,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..fab3497 --- /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 3c47135..0000000 --- a/test/test.js +++ /dev/null @@ -1,38 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is a function to open a file synchronously', function test( t ) { - t.equal( typeof open.sync, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 33b938f..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,110 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/main.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - open( __filename, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - open( __filename, 'r+', onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - open( __filename, 'r+', 438, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - open( 'beepboopbapbop', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', 438, onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); diff --git a/test/test.sync.js b/test/test.sync.js deleted file mode 100644 index 56d7b23..0000000 --- a/test/test.sync.js +++ /dev/null @@ -1,83 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/sync.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - var fd = open( __filename ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - var fd = open( __filename, 'r+' ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - var fd = open( __filename, 'r+', 438 ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - var fd = open( 'beepboopbapbop' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+', 438 ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); From 8ff11f70401f241e64b5a5de7ece02771a35bbfc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 00:58:28 +0000 Subject: [PATCH 060/113] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 07ecece..a79ef46 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.1.1", @@ -81,4 +82,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From cdff5a1a98ce094998295e41e786c86f5a80d9cc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 02:02:03 +0000 Subject: [PATCH 061/113] Remove files --- index.d.ts | 150 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6332 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 d52ee22..0000000 --- a/index.d.ts +++ /dev/null @@ -1,150 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Buffer } from 'buffer'; - -/** -* Callback invoked after opening a file. -* -* @param err - error argument -* @param fd - file descriptor -*/ -type Callback = ( err: Error, fd: number ) => void; - -/** -* Interface for opening a file. -*/ -interface Open { - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', 438, onOpen ); - */ - ( path: string | Buffer, flags: string | number, mode: number, clbk: Callback ): void; - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', onOpen ); - */ - ( path: string | Buffer, flags: string | number, clbk: Callback ): void; - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, onOpen ); - */ - ( path: string | Buffer, clbk: Callback ): void; - - /** - * Synchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @returns file descriptor or an error - * - * @example - * var closeSync = require( `@stdlib/fs/close` ).sync; - * - * var fd = open.sync( __filename, 'r+' ); - * if ( fd instanceof Error ) { - * throw fd; - * } - * closeSync( fd ); - */ - sync( path: string | Buffer, flags?: string | number, mode?: number ): number | Error; -} - -/** -* Asynchronously opens a file. -* -* @param path - file path -* @param flags - file system flags (default: 'r') -* @param mode - file mode (default: 0o666) -* @param clbk - callback to invoke after opening a file -* -* @example -* var closeSync = require( `@stdlib/fs/close` ).sync; -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( `@stdlib/fs/close` ).sync; -* -* var fd = open.sync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -declare var open: Open; - - -// EXPORTS // - -export = open; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index e60667a..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/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){if(this instanceof e){var n=[null];n.push.apply(n,arguments);var r=Function.bind.apply(t,n);return new r}return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}var n=t(Object.freeze({__proto__:null,default:{}})),r="r",o=438,u=n.open;function i(e,t,n,i){var a=arguments.length;return 2===a?u(e,r,o,t):3===a?u(e,t,o,n):void u(e,t,n,i)}var a=n.openSync;function p(e,t,n){var u,i;u=arguments.length;try{i=1===u?a(e,r,o):a(e,t,2===u?o:n)}catch(e){return e}return i}e(i,"sync",p);export{i as default,p as sync}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 5fee640..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;iqBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAIzB,CAFC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index fab3497..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 9550e51aee7048f3f32676aac3f4c2a5673b8c61 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 02:02:32 +0000 Subject: [PATCH 062/113] 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 | 55 +- SECURITY.md | 5 - benchmark/benchmark.js | 77 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 65 - docs/types/test.ts | 129 - examples/index.js | 56 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/defaults.json | 4 - lib/index.js | 63 - lib/main.js | 64 - lib/sync.js | 68 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 38 - test/test.main.js | 110 - test/test.sync.js | 83 - 47 files changed, 6211 insertions(+), 4116 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/defaults.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/sync.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.sync.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 4ad1a09..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-02-01T00:44:43.015Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index a3a4470..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/fs/open) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 7617ad3..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/fs/open) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 5865b49..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: '14 2 * * 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 + + ```
@@ -225,7 +222,7 @@ function onOpen( error, fd ) { ## 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]. @@ -292,11 +289,11 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close +[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close/tree/esm -[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists +[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists/tree/esm -[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file +[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file/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 503cc81..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,77 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var closeSync = require( '@stdlib/fs-close' ).sync; -var pkg = require( './../package.json' ).name; -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return open( __filename, 'r+', done ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function done( error, fd ) { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - if ( error ) { - b.fail( error.message ); - } - next(); - } -}); - -bench( pkg+':sync', function benchmark( b ) { - var fd; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - fd = open.sync( __filename, 'r+' ); - if ( fd instanceof Error ) { - b.fail( fd.message ); - } else { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - } - } - b.toc(); - if ( fd instanceof Error ) { - b.fail( 'something went wrong' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index da1ba5f..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/fs/open" -%% click B href "https://github.com/stdlib-js/fs-open/tree/main" -%% click C href "https://github.com/stdlib-js/fs-open/tree/production" -%% click D href "https://github.com/stdlib-js/fs-open/tree/esm" -%% click E href "https://github.com/stdlib-js/fs-open/tree/deno" -%% click F href "https://github.com/stdlib-js/fs-open/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/fs/open -[production-url]: https://github.com/stdlib-js/fs-open/tree/production -[deno-url]: https://github.com/stdlib-js/fs-open/tree/deno -[deno-readme]: https://github.com/stdlib-js/fs-open/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/fs-open/tree/umd -[umd-readme]: https://github.com/stdlib-js/fs-open/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/fs-open/tree/esm -[esm-readme]: https://github.com/stdlib-js/fs-open/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 3e10601..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import open from '../docs/types/index'; -export = open; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 5358415..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var u=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var i=u(function(b,y){y.exports={flags:"r",mode:438}});var d=u(function(j,f){ -var a=require("fs").open,o=i();function p(r,e,t,s){var n=arguments.length;if(n===2)return a(r,o.flags,o.mode,e);if(n===3)return a(r,e,o.mode,t);a(r,e,t,s)}f.exports=p -});var m=u(function(k,l){ -var c=require("fs").openSync,v=i();function x(r,e,t){var s,n;s=arguments.length;try{s===1?n=c(r,v.flags,v.mode):s===2?n=c(r,e,v.mode):n=c(r,e,t)}catch(g){return g}return n}l.exports=x -});var S=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),q=d(),O=m();S(q,"sync",O);module.exports=q; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 65b6278..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/main.js", "../lib/sync.js", "../lib/index.js"], - "sourcesContent": ["{\n\t\"flags\": \"r\",\n\t\"mode\": 438\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var open = require( '@stdlib/fs-open' );\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nmodule.exports = open;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nmodule.exports = openSync;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var open = require( '@stdlib/fs-open' );\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var openSync = require( '@stdlib/fs-open' ).sync;\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar sync = require( './sync.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,CAAAA,EAAA,SACC,MAAS,IACT,KAAQ,GACT,ICHA,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAK,QAAS,IAAK,EAAE,KACrBC,EAAW,IA0Bf,SAASC,EAAMC,EAAMC,EAAOC,EAAMC,EAAO,CACxC,IAAIC,EAAQ,UAAU,OACtB,GAAKA,IAAU,EACd,OAAOP,EAAIG,EAAMF,EAAS,MAAOA,EAAS,KAAMG,CAAM,EAEvD,GAAKG,IAAU,EACd,OAAOP,EAAIG,EAAMC,EAAOH,EAAS,KAAMI,CAAK,EAE7CL,EAAIG,EAAMC,EAAOC,EAAMC,CAAK,CAC7B,CAKAP,EAAO,QAAUG,IC/DjB,IAAAM,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAO,QAAS,IAAK,EAAE,SACvBC,EAAW,IAsBf,SAASC,EAAUC,EAAMC,EAAOC,EAAO,CACtC,IAAIC,EACAC,EAEJD,EAAQ,UAAU,OAClB,GAAI,CACEA,IAAU,EACdC,EAAKP,EAAMG,EAAMF,EAAS,MAAOA,EAAS,IAAK,EACpCK,IAAU,EACrBC,EAAKP,EAAMG,EAAMC,EAAOH,EAAS,IAAK,EAEtCM,EAAKP,EAAMG,EAAMC,EAAOC,CAAK,CAE/B,OAAUG,EAAM,CACf,OAAOA,CACR,CACA,OAAOD,CACR,CAKAR,EAAO,QAAUG,ICjBjB,IAAIO,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAO,IAKXF,EAAaC,EAAM,OAAQC,CAAK,EAKhC,OAAO,QAAUD", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_main", "__commonJSMin", "exports", "module", "op", "defaults", "open", "path", "flags", "mode", "clbk", "nargs", "require_sync", "__commonJSMin", "exports", "module", "open", "defaults", "openSync", "path", "flags", "mode", "nargs", "fd", "err", "setReadOnly", "main", "sync"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4cbf7ac..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,65 +0,0 @@ - -{{alias}}( path[, flags[, mode]], clbk ) - Asynchronously opens a file. - - Some characters, such as <>:"/\|?*, are reserved under Windows. - Under NTFS, if the path contains a colon, Node.js will open a file system - stream. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - clbk: Function - Callback to invoke upon opening a file. - - Examples - -------- - > function onOpen( error, fd ) { - ... if ( error ) { - ... console.error( error.message ); - ... } else { - ... {{alias:@stdlib/fs/close}}.sync( fd ); - ... } - ... }; - > {{alias}}( './beep/boop.txt', onOpen ); - - -{{alias}}.sync( path[, flags[, mode]] ) - Synchronously opens a file. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - Returns - ------- - fd: Error|integer - File descriptor. - - Examples - -------- - > var fd = {{alias}}.sync( './beep/boop.txt' ); - > if ( !{{alias:@stdlib/assert/is-error}}( fd ) ) { {{alias:@stdlib/fs/close}}.sync( fd ); }; - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 67907a2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,129 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 open = require( './index' ); - -const done = ( error: Error, fd: number ) => { - if ( error || !fd ) { - throw error; - } -}; - - -// TESTS // - -// The function does not have a return value... -{ - open( '/path/to/beepboop', done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a string... -{ - open( 123, done ); // $ExpectError - open( false, done ); // $ExpectError - open( true, done ); // $ExpectError - open( null, done ); // $ExpectError - open( undefined, done ); // $ExpectError - open( [], done ); // $ExpectError - open( {}, done ); // $ExpectError - open( ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a last argument which is not a function with the expected signature... -{ - open( '/path/to/beepboop', 'abc' ); // $ExpectError - open( '/path/to/beepboop', 123 ); // $ExpectError - open( '/path/to/beepboop', false ); // $ExpectError - open( '/path/to/beepboop', true ); // $ExpectError - open( '/path/to/beepboop', null ); // $ExpectError - open( '/path/to/beepboop', undefined ); // $ExpectError - open( '/path/to/beepboop', [] ); // $ExpectError - open( '/path/to/beepboop', {} ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `flags` argument which is not a string or number... -{ - open( '/path/to/beepboop', false, done ); // $ExpectError - open( '/path/to/beepboop', true, done ); // $ExpectError - open( '/path/to/beepboop', null, done ); // $ExpectError - open( '/path/to/beepboop', undefined, done ); // $ExpectError - open( '/path/to/beepboop', [], done ); // $ExpectError - open( '/path/to/beepboop', {}, done ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` argument which is not a number... -{ - open( '/path/to/beepboop', 'r+', 'abc', done ); // $ExpectError - open( '/path/to/beepboop', 'r+', false, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', true, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', null, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', undefined, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', [], done ); // $ExpectError - open( '/path/to/beepboop', 'r+', {}, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - open(); // $ExpectError - open( 'C:\\foo\\bar\\baz' ); // $ExpectError -} - -// Attached to main export is a `sync` method which returns a number or an error... -{ - open.sync( '/path/to/beepboop' ); // $ExpectType number | Error -} - -// The compiler throws an error if the `sync` method is provided a first argument which is not a string... -{ - open.sync( 123 ); // $ExpectError - open.sync( false ); // $ExpectError - open.sync( true ); // $ExpectError - open.sync( null ); // $ExpectError - open.sync( undefined ); // $ExpectError - open.sync( [] ); // $ExpectError - open.sync( {} ); // $ExpectError - open.sync( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a second argument which is not a string or number... -{ - open.sync( '/path/to/beepboop', false ); // $ExpectError - open.sync( '/path/to/beepboop', true ); // $ExpectError - open.sync( '/path/to/beepboop', null ); // $ExpectError - open.sync( '/path/to/beepboop', [] ); // $ExpectError - open.sync( '/path/to/beepboop', {} ); // $ExpectError - open.sync( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a third argument which is not a number... -{ - open.sync( '/path/to/beepboop', 'r+', false ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', true ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', null ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', [] ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', {} ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided an unsupported number of arguments... -{ - open.sync(); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 71359fe..0000000 --- a/examples/index.js +++ /dev/null @@ -1,56 +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. -*/ - -'use strict'; - -var closeSync = require( '@stdlib/fs-close' ).sync; -var isError = require( '@stdlib/assert-is-error' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - -/* Sync */ - -var fd = open.sync( __filename, 'r+' ); -// returns - -console.log( isError( fd ) ); -// => false - -closeSync( fd ); - -fd = open.sync( 'beepboop' ); -// returns - -console.log( isError( fd ) ); -// => true - -/* Async */ - -open( __filename, onOpen ); -open( 'beepboop', onOpen ); - -function onOpen( error, fd ) { - if ( error ) { - if ( error.code === 'ENOENT' ) { - console.error( 'File does not exist.' ); - } else { - throw error; - } - } else { - closeSync( fd ); - } -} 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..e60667a --- /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/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){if(this instanceof e){var n=[null];n.push.apply(n,arguments);var r=Function.bind.apply(t,n);return new r}return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}var n=t(Object.freeze({__proto__:null,default:{}})),r="r",o=438,u=n.open;function i(e,t,n,i){var a=arguments.length;return 2===a?u(e,r,o,t):3===a?u(e,t,o,n):void u(e,t,n,i)}var a=n.openSync;function p(e,t,n){var u,i;u=arguments.length;try{i=1===u?a(e,r,o):a(e,t,2===u?o:n)}catch(e){return e}return i}e(i,"sync",p);export{i as default,p as sync}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..5fee640 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;iqBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAIzB,CAFC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index cb174b7..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "flags": "r", - "mode": 438 -} diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 8edd6de..0000000 --- a/lib/index.js +++ /dev/null @@ -1,63 +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. -*/ - -'use strict'; - -/** -* Open a file. -* -* @module @stdlib/fs-open -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var openSync = require( '@stdlib/fs-open' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var sync = require( './sync.js' ); - - -// MAIN // - -setReadOnly( main, 'sync', sync ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index feb5171..0000000 --- a/lib/main.js +++ /dev/null @@ -1,64 +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. -*/ - -'use strict'; - -// MODULES // - -var op = require( 'fs' ).open; -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Asynchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @param {Function} clbk - callback to invoke after opening a file -* @returns {void} -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -*/ -function open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare - var nargs = arguments.length; - if ( nargs === 2 ) { - return op( path, defaults.flags, defaults.mode, flags ); - } - if ( nargs === 3 ) { - return op( path, flags, defaults.mode, mode ); - } - op( path, flags, mode, clbk ); -} - - -// EXPORTS // - -module.exports = open; diff --git a/lib/sync.js b/lib/sync.js deleted file mode 100644 index d8d2e00..0000000 --- a/lib/sync.js +++ /dev/null @@ -1,68 +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. -*/ - -'use strict'; - -// MODULES // - -var open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Synchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @returns {(integer|Error)} file descriptor or an error -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -function openSync( path, flags, mode ) { - var nargs; - var fd; - - nargs = arguments.length; - try { - if ( nargs === 1 ) { - fd = open( path, defaults.flags, defaults.mode ); - } else if ( nargs === 2 ) { - fd = open( path, flags, defaults.mode ); - } else { - fd = open( path, flags, mode ); - } - } catch ( err ) { - return err; - } - return fd; -} - - -// EXPORTS // - -module.exports = openSync; diff --git a/package.json b/package.json index a79ef46..337e340 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Open a file.", "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/utils-define-nonenumerable-read-only-property": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.1.1", - "@stdlib/assert-is-error": "^0.1.1", - "@stdlib/assert-is-nonnegative-integer": "^0.1.0", - "@stdlib/fs-close": "^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", "stdfs", @@ -82,4 +30,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..28b2cef --- /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 3c47135..0000000 --- a/test/test.js +++ /dev/null @@ -1,38 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is a function to open a file synchronously', function test( t ) { - t.equal( typeof open.sync, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 33b938f..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,110 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/main.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - open( __filename, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - open( __filename, 'r+', onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - open( __filename, 'r+', 438, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - open( 'beepboopbapbop', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', 438, onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); diff --git a/test/test.sync.js b/test/test.sync.js deleted file mode 100644 index 56d7b23..0000000 --- a/test/test.sync.js +++ /dev/null @@ -1,83 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/sync.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - var fd = open( __filename ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - var fd = open( __filename, 'r+' ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - var fd = open( __filename, 'r+', 438 ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - var fd = open( 'beepboopbapbop' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+', 438 ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); From 7989f0ffccafc7dfdc4336a696df1c17715726d8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 03:48:33 +0000 Subject: [PATCH 063/113] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ea6fd66..a91e8a7 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.0" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.0", + "@stdlib/error-tools-fmtprodmsg": "^0.2.0" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.1.1", @@ -81,4 +82,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 18d4f90eeabd800ea10332075d6254d563fd82fd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 04:35:04 +0000 Subject: [PATCH 064/113] Remove files --- index.d.ts | 150 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6332 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 dddbd0c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,150 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Buffer } from 'buffer'; - -/** -* Callback invoked after opening a file. -* -* @param err - error argument -* @param fd - file descriptor -*/ -type Callback = ( err: Error, fd: number ) => void; - -/** -* Interface for opening a file. -*/ -interface Open { - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', 438, onOpen ); - */ - ( path: string | Buffer, flags: string | number, mode: number, clbk: Callback ): void; - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', onOpen ); - */ - ( path: string | Buffer, flags: string | number, clbk: Callback ): void; - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, onOpen ); - */ - ( path: string | Buffer, clbk: Callback ): void; - - /** - * Synchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @returns file descriptor or an error - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * var fd = open.sync( __filename, 'r+' ); - * if ( fd instanceof Error ) { - * throw fd; - * } - * closeSync( fd ); - */ - sync( path: string | Buffer, flags?: string | number, mode?: number ): number | Error; -} - -/** -* Asynchronously opens a file. -* -* @param path - file path -* @param flags - file system flags (default: 'r') -* @param mode - file mode (default: 0o666) -* @param clbk - callback to invoke after opening a file -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* var fd = open.sync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -declare var open: Open; - - -// EXPORTS // - -export = open; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index e60667a..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/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){if(this instanceof e){var n=[null];n.push.apply(n,arguments);var r=Function.bind.apply(t,n);return new r}return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}var n=t(Object.freeze({__proto__:null,default:{}})),r="r",o=438,u=n.open;function i(e,t,n,i){var a=arguments.length;return 2===a?u(e,r,o,t):3===a?u(e,t,o,n):void u(e,t,n,i)}var a=n.openSync;function p(e,t,n){var u,i;u=arguments.length;try{i=1===u?a(e,r,o):a(e,t,2===u?o:n)}catch(e){return e}return i}e(i,"sync",p);export{i as default,p as sync}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 5fee640..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;iqBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAIzB,CAFC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 28b2cef..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 9f46dbdab8cfefb770691d011749a0c210441bed Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 04:35:16 +0000 Subject: [PATCH 065/113] 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 | 55 +- SECURITY.md | 5 - benchmark/benchmark.js | 77 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 65 - docs/types/test.ts | 129 - examples/index.js | 56 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/defaults.json | 4 - lib/index.js | 63 - lib/main.js | 64 - lib/sync.js | 68 - package.json | 58 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 38 - test/test.main.js | 110 - test/test.sync.js | 83 - 46 files changed, 6211 insertions(+), 4119 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/defaults.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/sync.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.sync.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 a3a4470..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/fs/open) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 7617ad3..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/fs/open) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 e86b853..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: '14 2 * * 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 + + ```
@@ -225,7 +222,7 @@ function onOpen( error, fd ) { ## 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]. @@ -292,11 +289,11 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close +[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close/tree/esm -[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists +[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists/tree/esm -[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file +[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file/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 503cc81..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,77 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var closeSync = require( '@stdlib/fs-close' ).sync; -var pkg = require( './../package.json' ).name; -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return open( __filename, 'r+', done ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function done( error, fd ) { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - if ( error ) { - b.fail( error.message ); - } - next(); - } -}); - -bench( pkg+':sync', function benchmark( b ) { - var fd; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - fd = open.sync( __filename, 'r+' ); - if ( fd instanceof Error ) { - b.fail( fd.message ); - } else { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - } - } - b.toc(); - if ( fd instanceof Error ) { - b.fail( 'something went wrong' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index da1ba5f..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/fs/open" -%% click B href "https://github.com/stdlib-js/fs-open/tree/main" -%% click C href "https://github.com/stdlib-js/fs-open/tree/production" -%% click D href "https://github.com/stdlib-js/fs-open/tree/esm" -%% click E href "https://github.com/stdlib-js/fs-open/tree/deno" -%% click F href "https://github.com/stdlib-js/fs-open/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/fs/open -[production-url]: https://github.com/stdlib-js/fs-open/tree/production -[deno-url]: https://github.com/stdlib-js/fs-open/tree/deno -[deno-readme]: https://github.com/stdlib-js/fs-open/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/fs-open/tree/umd -[umd-readme]: https://github.com/stdlib-js/fs-open/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/fs-open/tree/esm -[esm-readme]: https://github.com/stdlib-js/fs-open/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 3e10601..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import open from '../docs/types/index'; -export = open; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 5358415..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var u=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var i=u(function(b,y){y.exports={flags:"r",mode:438}});var d=u(function(j,f){ -var a=require("fs").open,o=i();function p(r,e,t,s){var n=arguments.length;if(n===2)return a(r,o.flags,o.mode,e);if(n===3)return a(r,e,o.mode,t);a(r,e,t,s)}f.exports=p -});var m=u(function(k,l){ -var c=require("fs").openSync,v=i();function x(r,e,t){var s,n;s=arguments.length;try{s===1?n=c(r,v.flags,v.mode):s===2?n=c(r,e,v.mode):n=c(r,e,t)}catch(g){return g}return n}l.exports=x -});var S=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),q=d(),O=m();S(q,"sync",O);module.exports=q; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 65b6278..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/main.js", "../lib/sync.js", "../lib/index.js"], - "sourcesContent": ["{\n\t\"flags\": \"r\",\n\t\"mode\": 438\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var open = require( '@stdlib/fs-open' );\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nmodule.exports = open;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nmodule.exports = openSync;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var open = require( '@stdlib/fs-open' );\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var openSync = require( '@stdlib/fs-open' ).sync;\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar sync = require( './sync.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,CAAAA,EAAA,SACC,MAAS,IACT,KAAQ,GACT,ICHA,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAK,QAAS,IAAK,EAAE,KACrBC,EAAW,IA0Bf,SAASC,EAAMC,EAAMC,EAAOC,EAAMC,EAAO,CACxC,IAAIC,EAAQ,UAAU,OACtB,GAAKA,IAAU,EACd,OAAOP,EAAIG,EAAMF,EAAS,MAAOA,EAAS,KAAMG,CAAM,EAEvD,GAAKG,IAAU,EACd,OAAOP,EAAIG,EAAMC,EAAOH,EAAS,KAAMI,CAAK,EAE7CL,EAAIG,EAAMC,EAAOC,EAAMC,CAAK,CAC7B,CAKAP,EAAO,QAAUG,IC/DjB,IAAAM,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAO,QAAS,IAAK,EAAE,SACvBC,EAAW,IAsBf,SAASC,EAAUC,EAAMC,EAAOC,EAAO,CACtC,IAAIC,EACAC,EAEJD,EAAQ,UAAU,OAClB,GAAI,CACEA,IAAU,EACdC,EAAKP,EAAMG,EAAMF,EAAS,MAAOA,EAAS,IAAK,EACpCK,IAAU,EACrBC,EAAKP,EAAMG,EAAMC,EAAOH,EAAS,IAAK,EAEtCM,EAAKP,EAAMG,EAAMC,EAAOC,CAAK,CAE/B,OAAUG,EAAM,CACf,OAAOA,CACR,CACA,OAAOD,CACR,CAKAR,EAAO,QAAUG,ICjBjB,IAAIO,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAO,IAKXF,EAAaC,EAAM,OAAQC,CAAK,EAKhC,OAAO,QAAUD", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_main", "__commonJSMin", "exports", "module", "op", "defaults", "open", "path", "flags", "mode", "clbk", "nargs", "require_sync", "__commonJSMin", "exports", "module", "open", "defaults", "openSync", "path", "flags", "mode", "nargs", "fd", "err", "setReadOnly", "main", "sync"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4cbf7ac..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,65 +0,0 @@ - -{{alias}}( path[, flags[, mode]], clbk ) - Asynchronously opens a file. - - Some characters, such as <>:"/\|?*, are reserved under Windows. - Under NTFS, if the path contains a colon, Node.js will open a file system - stream. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - clbk: Function - Callback to invoke upon opening a file. - - Examples - -------- - > function onOpen( error, fd ) { - ... if ( error ) { - ... console.error( error.message ); - ... } else { - ... {{alias:@stdlib/fs/close}}.sync( fd ); - ... } - ... }; - > {{alias}}( './beep/boop.txt', onOpen ); - - -{{alias}}.sync( path[, flags[, mode]] ) - Synchronously opens a file. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - Returns - ------- - fd: Error|integer - File descriptor. - - Examples - -------- - > var fd = {{alias}}.sync( './beep/boop.txt' ); - > if ( !{{alias:@stdlib/assert/is-error}}( fd ) ) { {{alias:@stdlib/fs/close}}.sync( fd ); }; - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 67907a2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,129 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 open = require( './index' ); - -const done = ( error: Error, fd: number ) => { - if ( error || !fd ) { - throw error; - } -}; - - -// TESTS // - -// The function does not have a return value... -{ - open( '/path/to/beepboop', done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a string... -{ - open( 123, done ); // $ExpectError - open( false, done ); // $ExpectError - open( true, done ); // $ExpectError - open( null, done ); // $ExpectError - open( undefined, done ); // $ExpectError - open( [], done ); // $ExpectError - open( {}, done ); // $ExpectError - open( ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a last argument which is not a function with the expected signature... -{ - open( '/path/to/beepboop', 'abc' ); // $ExpectError - open( '/path/to/beepboop', 123 ); // $ExpectError - open( '/path/to/beepboop', false ); // $ExpectError - open( '/path/to/beepboop', true ); // $ExpectError - open( '/path/to/beepboop', null ); // $ExpectError - open( '/path/to/beepboop', undefined ); // $ExpectError - open( '/path/to/beepboop', [] ); // $ExpectError - open( '/path/to/beepboop', {} ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `flags` argument which is not a string or number... -{ - open( '/path/to/beepboop', false, done ); // $ExpectError - open( '/path/to/beepboop', true, done ); // $ExpectError - open( '/path/to/beepboop', null, done ); // $ExpectError - open( '/path/to/beepboop', undefined, done ); // $ExpectError - open( '/path/to/beepboop', [], done ); // $ExpectError - open( '/path/to/beepboop', {}, done ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` argument which is not a number... -{ - open( '/path/to/beepboop', 'r+', 'abc', done ); // $ExpectError - open( '/path/to/beepboop', 'r+', false, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', true, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', null, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', undefined, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', [], done ); // $ExpectError - open( '/path/to/beepboop', 'r+', {}, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - open(); // $ExpectError - open( 'C:\\foo\\bar\\baz' ); // $ExpectError -} - -// Attached to main export is a `sync` method which returns a number or an error... -{ - open.sync( '/path/to/beepboop' ); // $ExpectType number | Error -} - -// The compiler throws an error if the `sync` method is provided a first argument which is not a string... -{ - open.sync( 123 ); // $ExpectError - open.sync( false ); // $ExpectError - open.sync( true ); // $ExpectError - open.sync( null ); // $ExpectError - open.sync( undefined ); // $ExpectError - open.sync( [] ); // $ExpectError - open.sync( {} ); // $ExpectError - open.sync( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a second argument which is not a string or number... -{ - open.sync( '/path/to/beepboop', false ); // $ExpectError - open.sync( '/path/to/beepboop', true ); // $ExpectError - open.sync( '/path/to/beepboop', null ); // $ExpectError - open.sync( '/path/to/beepboop', [] ); // $ExpectError - open.sync( '/path/to/beepboop', {} ); // $ExpectError - open.sync( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a third argument which is not a number... -{ - open.sync( '/path/to/beepboop', 'r+', false ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', true ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', null ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', [] ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', {} ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided an unsupported number of arguments... -{ - open.sync(); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 71359fe..0000000 --- a/examples/index.js +++ /dev/null @@ -1,56 +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. -*/ - -'use strict'; - -var closeSync = require( '@stdlib/fs-close' ).sync; -var isError = require( '@stdlib/assert-is-error' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - -/* Sync */ - -var fd = open.sync( __filename, 'r+' ); -// returns - -console.log( isError( fd ) ); -// => false - -closeSync( fd ); - -fd = open.sync( 'beepboop' ); -// returns - -console.log( isError( fd ) ); -// => true - -/* Async */ - -open( __filename, onOpen ); -open( 'beepboop', onOpen ); - -function onOpen( error, fd ) { - if ( error ) { - if ( error.code === 'ENOENT' ) { - console.error( 'File does not exist.' ); - } else { - throw error; - } - } else { - closeSync( fd ); - } -} 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..e60667a --- /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/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){if(this instanceof e){var n=[null];n.push.apply(n,arguments);var r=Function.bind.apply(t,n);return new r}return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}var n=t(Object.freeze({__proto__:null,default:{}})),r="r",o=438,u=n.open;function i(e,t,n,i){var a=arguments.length;return 2===a?u(e,r,o,t):3===a?u(e,t,o,n):void u(e,t,n,i)}var a=n.openSync;function p(e,t,n){var u,i;u=arguments.length;try{i=1===u?a(e,r,o):a(e,t,2===u?o:n)}catch(e){return e}return i}e(i,"sync",p);export{i as default,p as sync}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..5fee640 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;iqBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAIzB,CAFC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index cb174b7..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "flags": "r", - "mode": 438 -} diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 8edd6de..0000000 --- a/lib/index.js +++ /dev/null @@ -1,63 +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. -*/ - -'use strict'; - -/** -* Open a file. -* -* @module @stdlib/fs-open -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var openSync = require( '@stdlib/fs-open' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var sync = require( './sync.js' ); - - -// MAIN // - -setReadOnly( main, 'sync', sync ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index feb5171..0000000 --- a/lib/main.js +++ /dev/null @@ -1,64 +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. -*/ - -'use strict'; - -// MODULES // - -var op = require( 'fs' ).open; -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Asynchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @param {Function} clbk - callback to invoke after opening a file -* @returns {void} -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -*/ -function open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare - var nargs = arguments.length; - if ( nargs === 2 ) { - return op( path, defaults.flags, defaults.mode, flags ); - } - if ( nargs === 3 ) { - return op( path, flags, defaults.mode, mode ); - } - op( path, flags, mode, clbk ); -} - - -// EXPORTS // - -module.exports = open; diff --git a/lib/sync.js b/lib/sync.js deleted file mode 100644 index d8d2e00..0000000 --- a/lib/sync.js +++ /dev/null @@ -1,68 +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. -*/ - -'use strict'; - -// MODULES // - -var open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Synchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @returns {(integer|Error)} file descriptor or an error -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -function openSync( path, flags, mode ) { - var nargs; - var fd; - - nargs = arguments.length; - try { - if ( nargs === 1 ) { - fd = open( path, defaults.flags, defaults.mode ); - } else if ( nargs === 2 ) { - fd = open( path, flags, defaults.mode ); - } else { - fd = open( path, flags, mode ); - } - } catch ( err ) { - return err; - } - return fd; -} - - -// EXPORTS // - -module.exports = openSync; diff --git a/package.json b/package.json index a91e8a7..e00344f 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.0", "description": "Open a file.", "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/utils-define-nonenumerable-read-only-property": "^0.2.0", - "@stdlib/error-tools-fmtprodmsg": "^0.2.0" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.1.1", - "@stdlib/assert-is-error": "^0.1.1", - "@stdlib/assert-is-nonnegative-integer": "^0.1.0", - "@stdlib/fs-close": "^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", "stdfs", @@ -82,4 +30,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..4b3f9df --- /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 3c47135..0000000 --- a/test/test.js +++ /dev/null @@ -1,38 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is a function to open a file synchronously', function test( t ) { - t.equal( typeof open.sync, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 33b938f..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,110 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/main.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - open( __filename, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - open( __filename, 'r+', onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - open( __filename, 'r+', 438, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - open( 'beepboopbapbop', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', 438, onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); diff --git a/test/test.sync.js b/test/test.sync.js deleted file mode 100644 index 56d7b23..0000000 --- a/test/test.sync.js +++ /dev/null @@ -1,83 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/sync.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - var fd = open( __filename ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - var fd = open( __filename, 'r+' ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - var fd = open( __filename, 'r+', 438 ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - var fd = open( 'beepboopbapbop' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+', 438 ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); From 97d40cdd0a847106c3d271fd650e81978f0cedf7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 05:14:06 +0000 Subject: [PATCH 066/113] Update README.md for ESM bundle v0.2.0 --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 6de4c5e..787a26e 100644 --- a/README.md +++ b/README.md @@ -44,13 +44,13 @@ limitations under the License. ```javascript -import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@esm/index.mjs'; +import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@v0.2.0-esm/index.mjs'; ``` You can also import the following named exports from the package: ```javascript -import { sync } from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@esm/index.mjs'; +import { sync } from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@v0.2.0-esm/index.mjs'; ``` #### open( path\[, flags\[, mode]], clbk ) @@ -123,7 +123,7 @@ The function has the same default parameters as [`fs.openSync()`][node-fs]. ```javascript - import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@esm/index.mjs'; + import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@v0.2.0-esm/index.mjs'; var fpath = '/path/to/file.js'; @@ -155,7 +155,7 @@ The function has the same default parameters as [`fs.openSync()`][node-fs]. var join = require( 'path' ).join; var closeSync = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-close' ).sync; -import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@esm/index.mjs'; +import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@v0.2.0-esm/index.mjs'; /* Sync */ From 30f512f6f4297ca9f135dfa7675a9d2064e06182 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 05:14:07 +0000 Subject: [PATCH 067/113] Auto-generated commit --- README.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 787a26e..6290803 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,11 @@ limitations under the License. +```javascript +import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@esm/index.mjs'; +``` +The previous example will load the latest bundled code from the esm branch. Alternatively, you may load a specific version by loading the file from one of the [tagged bundles](https://github.com/stdlib-js/fs-open/tags). For example, + ```javascript import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@v0.2.0-esm/index.mjs'; ``` @@ -50,7 +55,7 @@ import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@v0.2.0-esm/index You can also import the following named exports from the package: ```javascript -import { sync } from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@v0.2.0-esm/index.mjs'; +import { sync } from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@esm/index.mjs'; ``` #### open( path\[, flags\[, mode]], clbk ) @@ -123,7 +128,7 @@ The function has the same default parameters as [`fs.openSync()`][node-fs]. ```javascript - import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@v0.2.0-esm/index.mjs'; + import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@esm/index.mjs'; var fpath = '/path/to/file.js'; @@ -155,7 +160,7 @@ The function has the same default parameters as [`fs.openSync()`][node-fs]. var join = require( 'path' ).join; var closeSync = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-close' ).sync; -import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@v0.2.0-esm/index.mjs'; +import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@esm/index.mjs'; /* Sync */ From 9c0e9a57bcb27027ff463ff1ab3e2a06fe07d0b6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 21 Feb 2024 21:45:08 +0000 Subject: [PATCH 068/113] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 4898bac..bc1ae2e 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.2.0", @@ -81,4 +82,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 0d2c8d17801f8813291677e32d818ed1d390e08b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 21 Feb 2024 22:08:41 +0000 Subject: [PATCH 069/113] Remove files --- index.d.ts | 150 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6332 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 dddbd0c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,150 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Buffer } from 'buffer'; - -/** -* Callback invoked after opening a file. -* -* @param err - error argument -* @param fd - file descriptor -*/ -type Callback = ( err: Error, fd: number ) => void; - -/** -* Interface for opening a file. -*/ -interface Open { - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', 438, onOpen ); - */ - ( path: string | Buffer, flags: string | number, mode: number, clbk: Callback ): void; - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', onOpen ); - */ - ( path: string | Buffer, flags: string | number, clbk: Callback ): void; - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, onOpen ); - */ - ( path: string | Buffer, clbk: Callback ): void; - - /** - * Synchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @returns file descriptor or an error - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * var fd = open.sync( __filename, 'r+' ); - * if ( fd instanceof Error ) { - * throw fd; - * } - * closeSync( fd ); - */ - sync( path: string | Buffer, flags?: string | number, mode?: number ): number | Error; -} - -/** -* Asynchronously opens a file. -* -* @param path - file path -* @param flags - file system flags (default: 'r') -* @param mode - file mode (default: 0o666) -* @param clbk - callback to invoke after opening a file -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* var fd = open.sync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -declare var open: Open; - - -// EXPORTS // - -export = open; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index e60667a..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/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){if(this instanceof e){var n=[null];n.push.apply(n,arguments);var r=Function.bind.apply(t,n);return new r}return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}var n=t(Object.freeze({__proto__:null,default:{}})),r="r",o=438,u=n.open;function i(e,t,n,i){var a=arguments.length;return 2===a?u(e,r,o,t):3===a?u(e,t,o,n):void u(e,t,n,i)}var a=n.openSync;function p(e,t,n){var u,i;u=arguments.length;try{i=1===u?a(e,r,o):a(e,t,2===u?o:n)}catch(e){return e}return i}e(i,"sync",p);export{i as default,p as sync}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 5fee640..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;iqBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAIzB,CAFC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 4b3f9df..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From bf9e29eacf434cce1d567c8b4503a6152a6d78a2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 21 Feb 2024 22:08:53 +0000 Subject: [PATCH 070/113] 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 | 55 +- SECURITY.md | 5 - benchmark/benchmark.js | 77 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 65 - docs/types/test.ts | 129 - examples/index.js | 56 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/defaults.json | 4 - lib/index.js | 63 - lib/main.js | 64 - lib/sync.js | 68 - package.json | 58 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 38 - test/test.main.js | 110 - test/test.sync.js | 83 - 46 files changed, 4876 insertions(+), 4113 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/defaults.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/sync.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.sync.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 a3a4470..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/fs/open) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 7617ad3..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/fs/open) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 d7fc8a0..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: '14 2 * * 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 + + ```
@@ -225,7 +222,7 @@ function onOpen( error, fd ) { ## 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]. @@ -292,11 +289,11 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close +[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close/tree/esm -[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists +[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists/tree/esm -[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file +[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file/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 503cc81..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,77 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var closeSync = require( '@stdlib/fs-close' ).sync; -var pkg = require( './../package.json' ).name; -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return open( __filename, 'r+', done ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function done( error, fd ) { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - if ( error ) { - b.fail( error.message ); - } - next(); - } -}); - -bench( pkg+':sync', function benchmark( b ) { - var fd; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - fd = open.sync( __filename, 'r+' ); - if ( fd instanceof Error ) { - b.fail( fd.message ); - } else { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - } - } - b.toc(); - if ( fd instanceof Error ) { - b.fail( 'something went wrong' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index da1ba5f..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/fs/open" -%% click B href "https://github.com/stdlib-js/fs-open/tree/main" -%% click C href "https://github.com/stdlib-js/fs-open/tree/production" -%% click D href "https://github.com/stdlib-js/fs-open/tree/esm" -%% click E href "https://github.com/stdlib-js/fs-open/tree/deno" -%% click F href "https://github.com/stdlib-js/fs-open/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/fs/open -[production-url]: https://github.com/stdlib-js/fs-open/tree/production -[deno-url]: https://github.com/stdlib-js/fs-open/tree/deno -[deno-readme]: https://github.com/stdlib-js/fs-open/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/fs-open/tree/umd -[umd-readme]: https://github.com/stdlib-js/fs-open/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/fs-open/tree/esm -[esm-readme]: https://github.com/stdlib-js/fs-open/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 3e10601..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import open from '../docs/types/index'; -export = open; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 5358415..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var u=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var i=u(function(b,y){y.exports={flags:"r",mode:438}});var d=u(function(j,f){ -var a=require("fs").open,o=i();function p(r,e,t,s){var n=arguments.length;if(n===2)return a(r,o.flags,o.mode,e);if(n===3)return a(r,e,o.mode,t);a(r,e,t,s)}f.exports=p -});var m=u(function(k,l){ -var c=require("fs").openSync,v=i();function x(r,e,t){var s,n;s=arguments.length;try{s===1?n=c(r,v.flags,v.mode):s===2?n=c(r,e,v.mode):n=c(r,e,t)}catch(g){return g}return n}l.exports=x -});var S=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),q=d(),O=m();S(q,"sync",O);module.exports=q; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 65b6278..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/main.js", "../lib/sync.js", "../lib/index.js"], - "sourcesContent": ["{\n\t\"flags\": \"r\",\n\t\"mode\": 438\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var open = require( '@stdlib/fs-open' );\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nmodule.exports = open;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nmodule.exports = openSync;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var open = require( '@stdlib/fs-open' );\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var openSync = require( '@stdlib/fs-open' ).sync;\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar sync = require( './sync.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,CAAAA,EAAA,SACC,MAAS,IACT,KAAQ,GACT,ICHA,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAK,QAAS,IAAK,EAAE,KACrBC,EAAW,IA0Bf,SAASC,EAAMC,EAAMC,EAAOC,EAAMC,EAAO,CACxC,IAAIC,EAAQ,UAAU,OACtB,GAAKA,IAAU,EACd,OAAOP,EAAIG,EAAMF,EAAS,MAAOA,EAAS,KAAMG,CAAM,EAEvD,GAAKG,IAAU,EACd,OAAOP,EAAIG,EAAMC,EAAOH,EAAS,KAAMI,CAAK,EAE7CL,EAAIG,EAAMC,EAAOC,EAAMC,CAAK,CAC7B,CAKAP,EAAO,QAAUG,IC/DjB,IAAAM,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAO,QAAS,IAAK,EAAE,SACvBC,EAAW,IAsBf,SAASC,EAAUC,EAAMC,EAAOC,EAAO,CACtC,IAAIC,EACAC,EAEJD,EAAQ,UAAU,OAClB,GAAI,CACEA,IAAU,EACdC,EAAKP,EAAMG,EAAMF,EAAS,MAAOA,EAAS,IAAK,EACpCK,IAAU,EACrBC,EAAKP,EAAMG,EAAMC,EAAOH,EAAS,IAAK,EAEtCM,EAAKP,EAAMG,EAAMC,EAAOC,CAAK,CAE/B,OAAUG,EAAM,CACf,OAAOA,CACR,CACA,OAAOD,CACR,CAKAR,EAAO,QAAUG,ICjBjB,IAAIO,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAO,IAKXF,EAAaC,EAAM,OAAQC,CAAK,EAKhC,OAAO,QAAUD", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_main", "__commonJSMin", "exports", "module", "op", "defaults", "open", "path", "flags", "mode", "clbk", "nargs", "require_sync", "__commonJSMin", "exports", "module", "open", "defaults", "openSync", "path", "flags", "mode", "nargs", "fd", "err", "setReadOnly", "main", "sync"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4cbf7ac..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,65 +0,0 @@ - -{{alias}}( path[, flags[, mode]], clbk ) - Asynchronously opens a file. - - Some characters, such as <>:"/\|?*, are reserved under Windows. - Under NTFS, if the path contains a colon, Node.js will open a file system - stream. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - clbk: Function - Callback to invoke upon opening a file. - - Examples - -------- - > function onOpen( error, fd ) { - ... if ( error ) { - ... console.error( error.message ); - ... } else { - ... {{alias:@stdlib/fs/close}}.sync( fd ); - ... } - ... }; - > {{alias}}( './beep/boop.txt', onOpen ); - - -{{alias}}.sync( path[, flags[, mode]] ) - Synchronously opens a file. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - Returns - ------- - fd: Error|integer - File descriptor. - - Examples - -------- - > var fd = {{alias}}.sync( './beep/boop.txt' ); - > if ( !{{alias:@stdlib/assert/is-error}}( fd ) ) { {{alias:@stdlib/fs/close}}.sync( fd ); }; - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 67907a2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,129 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 open = require( './index' ); - -const done = ( error: Error, fd: number ) => { - if ( error || !fd ) { - throw error; - } -}; - - -// TESTS // - -// The function does not have a return value... -{ - open( '/path/to/beepboop', done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a string... -{ - open( 123, done ); // $ExpectError - open( false, done ); // $ExpectError - open( true, done ); // $ExpectError - open( null, done ); // $ExpectError - open( undefined, done ); // $ExpectError - open( [], done ); // $ExpectError - open( {}, done ); // $ExpectError - open( ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a last argument which is not a function with the expected signature... -{ - open( '/path/to/beepboop', 'abc' ); // $ExpectError - open( '/path/to/beepboop', 123 ); // $ExpectError - open( '/path/to/beepboop', false ); // $ExpectError - open( '/path/to/beepboop', true ); // $ExpectError - open( '/path/to/beepboop', null ); // $ExpectError - open( '/path/to/beepboop', undefined ); // $ExpectError - open( '/path/to/beepboop', [] ); // $ExpectError - open( '/path/to/beepboop', {} ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `flags` argument which is not a string or number... -{ - open( '/path/to/beepboop', false, done ); // $ExpectError - open( '/path/to/beepboop', true, done ); // $ExpectError - open( '/path/to/beepboop', null, done ); // $ExpectError - open( '/path/to/beepboop', undefined, done ); // $ExpectError - open( '/path/to/beepboop', [], done ); // $ExpectError - open( '/path/to/beepboop', {}, done ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` argument which is not a number... -{ - open( '/path/to/beepboop', 'r+', 'abc', done ); // $ExpectError - open( '/path/to/beepboop', 'r+', false, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', true, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', null, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', undefined, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', [], done ); // $ExpectError - open( '/path/to/beepboop', 'r+', {}, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - open(); // $ExpectError - open( 'C:\\foo\\bar\\baz' ); // $ExpectError -} - -// Attached to main export is a `sync` method which returns a number or an error... -{ - open.sync( '/path/to/beepboop' ); // $ExpectType number | Error -} - -// The compiler throws an error if the `sync` method is provided a first argument which is not a string... -{ - open.sync( 123 ); // $ExpectError - open.sync( false ); // $ExpectError - open.sync( true ); // $ExpectError - open.sync( null ); // $ExpectError - open.sync( undefined ); // $ExpectError - open.sync( [] ); // $ExpectError - open.sync( {} ); // $ExpectError - open.sync( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a second argument which is not a string or number... -{ - open.sync( '/path/to/beepboop', false ); // $ExpectError - open.sync( '/path/to/beepboop', true ); // $ExpectError - open.sync( '/path/to/beepboop', null ); // $ExpectError - open.sync( '/path/to/beepboop', [] ); // $ExpectError - open.sync( '/path/to/beepboop', {} ); // $ExpectError - open.sync( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a third argument which is not a number... -{ - open.sync( '/path/to/beepboop', 'r+', false ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', true ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', null ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', [] ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', {} ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided an unsupported number of arguments... -{ - open.sync(); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 71359fe..0000000 --- a/examples/index.js +++ /dev/null @@ -1,56 +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. -*/ - -'use strict'; - -var closeSync = require( '@stdlib/fs-close' ).sync; -var isError = require( '@stdlib/assert-is-error' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - -/* Sync */ - -var fd = open.sync( __filename, 'r+' ); -// returns - -console.log( isError( fd ) ); -// => false - -closeSync( fd ); - -fd = open.sync( 'beepboop' ); -// returns - -console.log( isError( fd ) ); -// => true - -/* Async */ - -open( __filename, onOpen ); -open( 'beepboop', onOpen ); - -function onOpen( error, fd ) { - if ( error ) { - if ( error.code === 'ENOENT' ) { - console.error( 'File does not exist.' ); - } else { - throw error; - } - } else { - closeSync( fd ); - } -} 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..9e3afbc --- /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/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var r=t(Object.freeze({__proto__:null,default:{}})),n="r",o=438,c=r.open;function u(e,t,r,u){var i=arguments.length;return 2===i?c(e,n,o,t):3===i?c(e,t,o,r):void c(e,t,r,u)}var i=r.openSync;function s(e,t,r){var c,u;c=arguments.length;try{u=1===c?i(e,n,o):i(e,t,2===c?o:r)}catch(e){return e}return u}e(u,"sync",s);export{u as default,s as sync}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..0d9f33f --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;0nBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAEzB,CAAC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index cb174b7..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "flags": "r", - "mode": 438 -} diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 8edd6de..0000000 --- a/lib/index.js +++ /dev/null @@ -1,63 +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. -*/ - -'use strict'; - -/** -* Open a file. -* -* @module @stdlib/fs-open -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var openSync = require( '@stdlib/fs-open' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var sync = require( './sync.js' ); - - -// MAIN // - -setReadOnly( main, 'sync', sync ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index feb5171..0000000 --- a/lib/main.js +++ /dev/null @@ -1,64 +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. -*/ - -'use strict'; - -// MODULES // - -var op = require( 'fs' ).open; -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Asynchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @param {Function} clbk - callback to invoke after opening a file -* @returns {void} -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -*/ -function open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare - var nargs = arguments.length; - if ( nargs === 2 ) { - return op( path, defaults.flags, defaults.mode, flags ); - } - if ( nargs === 3 ) { - return op( path, flags, defaults.mode, mode ); - } - op( path, flags, mode, clbk ); -} - - -// EXPORTS // - -module.exports = open; diff --git a/lib/sync.js b/lib/sync.js deleted file mode 100644 index d8d2e00..0000000 --- a/lib/sync.js +++ /dev/null @@ -1,68 +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. -*/ - -'use strict'; - -// MODULES // - -var open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Synchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @returns {(integer|Error)} file descriptor or an error -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -function openSync( path, flags, mode ) { - var nargs; - var fd; - - nargs = arguments.length; - try { - if ( nargs === 1 ) { - fd = open( path, defaults.flags, defaults.mode ); - } else if ( nargs === 2 ) { - fd = open( path, flags, defaults.mode ); - } else { - fd = open( path, flags, mode ); - } - } catch ( err ) { - return err; - } - return fd; -} - - -// EXPORTS // - -module.exports = openSync; diff --git a/package.json b/package.json index bc1ae2e..b313f37 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Open a file.", "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/utils-define-nonenumerable-read-only-property": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.2.0", - "@stdlib/assert-is-error": "^0.2.0", - "@stdlib/assert-is-nonnegative-integer": "^0.2.0", - "@stdlib/fs-close": "^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", "stdfs", @@ -82,4 +30,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..34bd866 --- /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 3c47135..0000000 --- a/test/test.js +++ /dev/null @@ -1,38 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is a function to open a file synchronously', function test( t ) { - t.equal( typeof open.sync, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 33b938f..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,110 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/main.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - open( __filename, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - open( __filename, 'r+', onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - open( __filename, 'r+', 438, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - open( 'beepboopbapbop', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', 438, onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); diff --git a/test/test.sync.js b/test/test.sync.js deleted file mode 100644 index 56d7b23..0000000 --- a/test/test.sync.js +++ /dev/null @@ -1,83 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/sync.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - var fd = open( __filename ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - var fd = open( __filename, 'r+' ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - var fd = open( __filename, 'r+', 438 ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - var fd = open( 'beepboopbapbop' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+', 438 ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); From 517157654d19134446446964a72691861ab334e0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 21 Feb 2024 22:27:06 +0000 Subject: [PATCH 071/113] Update README.md for ESM bundle v0.2.1 --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 35a348d..76a53a0 100644 --- a/README.md +++ b/README.md @@ -44,13 +44,13 @@ limitations under the License. ```javascript -import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@esm/index.mjs'; +import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@v0.2.1-esm/index.mjs'; ``` You can also import the following named exports from the package: ```javascript -import { sync } from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@esm/index.mjs'; +import { sync } from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@v0.2.1-esm/index.mjs'; ``` #### open( path\[, flags\[, mode]], clbk ) @@ -123,7 +123,7 @@ The function has the same default parameters as [`fs.openSync()`][node-fs]. ```javascript - import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@esm/index.mjs'; + import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@v0.2.1-esm/index.mjs'; var fpath = '/path/to/file.js'; @@ -155,7 +155,7 @@ The function has the same default parameters as [`fs.openSync()`][node-fs]. var join = require( 'path' ).join; var closeSync = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-close' ).sync; -import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@esm/index.mjs'; +import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@v0.2.1-esm/index.mjs'; /* Sync */ From bb41389ec89050783a699f9f6c2b52ed2a56a23b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 21 Feb 2024 22:27:07 +0000 Subject: [PATCH 072/113] Auto-generated commit --- README.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 76a53a0..2b27b18 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,11 @@ limitations under the License. +```javascript +import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@esm/index.mjs'; +``` +The previous example will load the latest bundled code from the esm branch. Alternatively, you may load a specific version by loading the file from one of the [tagged bundles](https://github.com/stdlib-js/fs-open/tags). For example, + ```javascript import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@v0.2.1-esm/index.mjs'; ``` @@ -50,7 +55,7 @@ import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@v0.2.1-esm/index You can also import the following named exports from the package: ```javascript -import { sync } from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@v0.2.1-esm/index.mjs'; +import { sync } from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@esm/index.mjs'; ``` #### open( path\[, flags\[, mode]], clbk ) @@ -123,7 +128,7 @@ The function has the same default parameters as [`fs.openSync()`][node-fs]. ```javascript - import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@v0.2.1-esm/index.mjs'; + import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@esm/index.mjs'; var fpath = '/path/to/file.js'; @@ -155,7 +160,7 @@ The function has the same default parameters as [`fs.openSync()`][node-fs]. var join = require( 'path' ).join; var closeSync = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-close' ).sync; -import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@v0.2.1-esm/index.mjs'; +import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@esm/index.mjs'; /* Sync */ From 2ff1c0e144ab70528b5b7cfb6ff3871576c31e61 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 00:53:55 +0000 Subject: [PATCH 073/113] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 8dbf5e0..b373e1d 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.2.1", @@ -81,4 +82,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From fce56f6cff7491c611396f6667db2209f976c961 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 01:26:59 +0000 Subject: [PATCH 074/113] Remove files --- index.d.ts | 150 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4997 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 dddbd0c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,150 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Buffer } from 'buffer'; - -/** -* Callback invoked after opening a file. -* -* @param err - error argument -* @param fd - file descriptor -*/ -type Callback = ( err: Error, fd: number ) => void; - -/** -* Interface for opening a file. -*/ -interface Open { - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', 438, onOpen ); - */ - ( path: string | Buffer, flags: string | number, mode: number, clbk: Callback ): void; - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', onOpen ); - */ - ( path: string | Buffer, flags: string | number, clbk: Callback ): void; - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, onOpen ); - */ - ( path: string | Buffer, clbk: Callback ): void; - - /** - * Synchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @returns file descriptor or an error - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * var fd = open.sync( __filename, 'r+' ); - * if ( fd instanceof Error ) { - * throw fd; - * } - * closeSync( fd ); - */ - sync( path: string | Buffer, flags?: string | number, mode?: number ): number | Error; -} - -/** -* Asynchronously opens a file. -* -* @param path - file path -* @param flags - file system flags (default: 'r') -* @param mode - file mode (default: 0o666) -* @param clbk - callback to invoke after opening a file -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* var fd = open.sync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -declare var open: Open; - - -// EXPORTS // - -export = open; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 9e3afbc..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/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var r=t(Object.freeze({__proto__:null,default:{}})),n="r",o=438,c=r.open;function u(e,t,r,u){var i=arguments.length;return 2===i?c(e,n,o,t):3===i?c(e,t,o,r):void c(e,t,r,u)}var i=r.openSync;function s(e,t,r){var c,u;c=arguments.length;try{u=1===c?i(e,n,o):i(e,t,2===c?o:r)}catch(e){return e}return u}e(u,"sync",s);export{u as default,s as sync}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 0d9f33f..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;0nBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAEzB,CAAC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 34bd866..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 8d8663ebbf21e94ca0ed7abbde2382e6de6e6192 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 01:27:10 +0000 Subject: [PATCH 075/113] 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 | 55 +- SECURITY.md | 5 - benchmark/benchmark.js | 77 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 65 - docs/types/test.ts | 129 - examples/index.js | 56 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/defaults.json | 4 - lib/index.js | 63 - lib/main.js | 64 - lib/sync.js | 68 - package.json | 58 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 38 - test/test.main.js | 110 - test/test.sync.js | 83 - 47 files changed, 4876 insertions(+), 4115 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (100%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/defaults.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/sync.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.sync.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 a94322d..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-03-01T00:46:27.141Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index a3a4470..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/fs/open) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 7617ad3..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/fs/open) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 d7fc8a0..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: '14 2 * * 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 + + ```
@@ -225,7 +222,7 @@ function onOpen( error, fd ) { ## 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]. @@ -292,11 +289,11 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close +[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close/tree/esm -[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists +[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists/tree/esm -[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file +[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file/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 503cc81..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,77 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var closeSync = require( '@stdlib/fs-close' ).sync; -var pkg = require( './../package.json' ).name; -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return open( __filename, 'r+', done ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function done( error, fd ) { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - if ( error ) { - b.fail( error.message ); - } - next(); - } -}); - -bench( pkg+':sync', function benchmark( b ) { - var fd; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - fd = open.sync( __filename, 'r+' ); - if ( fd instanceof Error ) { - b.fail( fd.message ); - } else { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - } - } - b.toc(); - if ( fd instanceof Error ) { - b.fail( 'something went wrong' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index da1ba5f..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/fs/open" -%% click B href "https://github.com/stdlib-js/fs-open/tree/main" -%% click C href "https://github.com/stdlib-js/fs-open/tree/production" -%% click D href "https://github.com/stdlib-js/fs-open/tree/esm" -%% click E href "https://github.com/stdlib-js/fs-open/tree/deno" -%% click F href "https://github.com/stdlib-js/fs-open/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/fs/open -[production-url]: https://github.com/stdlib-js/fs-open/tree/production -[deno-url]: https://github.com/stdlib-js/fs-open/tree/deno -[deno-readme]: https://github.com/stdlib-js/fs-open/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/fs-open/tree/umd -[umd-readme]: https://github.com/stdlib-js/fs-open/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/fs-open/tree/esm -[esm-readme]: https://github.com/stdlib-js/fs-open/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 3e10601..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import open from '../docs/types/index'; -export = open; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 5358415..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var u=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var i=u(function(b,y){y.exports={flags:"r",mode:438}});var d=u(function(j,f){ -var a=require("fs").open,o=i();function p(r,e,t,s){var n=arguments.length;if(n===2)return a(r,o.flags,o.mode,e);if(n===3)return a(r,e,o.mode,t);a(r,e,t,s)}f.exports=p -});var m=u(function(k,l){ -var c=require("fs").openSync,v=i();function x(r,e,t){var s,n;s=arguments.length;try{s===1?n=c(r,v.flags,v.mode):s===2?n=c(r,e,v.mode):n=c(r,e,t)}catch(g){return g}return n}l.exports=x -});var S=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),q=d(),O=m();S(q,"sync",O);module.exports=q; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 65b6278..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/main.js", "../lib/sync.js", "../lib/index.js"], - "sourcesContent": ["{\n\t\"flags\": \"r\",\n\t\"mode\": 438\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var open = require( '@stdlib/fs-open' );\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nmodule.exports = open;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nmodule.exports = openSync;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var open = require( '@stdlib/fs-open' );\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var openSync = require( '@stdlib/fs-open' ).sync;\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar sync = require( './sync.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,CAAAA,EAAA,SACC,MAAS,IACT,KAAQ,GACT,ICHA,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAK,QAAS,IAAK,EAAE,KACrBC,EAAW,IA0Bf,SAASC,EAAMC,EAAMC,EAAOC,EAAMC,EAAO,CACxC,IAAIC,EAAQ,UAAU,OACtB,GAAKA,IAAU,EACd,OAAOP,EAAIG,EAAMF,EAAS,MAAOA,EAAS,KAAMG,CAAM,EAEvD,GAAKG,IAAU,EACd,OAAOP,EAAIG,EAAMC,EAAOH,EAAS,KAAMI,CAAK,EAE7CL,EAAIG,EAAMC,EAAOC,EAAMC,CAAK,CAC7B,CAKAP,EAAO,QAAUG,IC/DjB,IAAAM,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAO,QAAS,IAAK,EAAE,SACvBC,EAAW,IAsBf,SAASC,EAAUC,EAAMC,EAAOC,EAAO,CACtC,IAAIC,EACAC,EAEJD,EAAQ,UAAU,OAClB,GAAI,CACEA,IAAU,EACdC,EAAKP,EAAMG,EAAMF,EAAS,MAAOA,EAAS,IAAK,EACpCK,IAAU,EACrBC,EAAKP,EAAMG,EAAMC,EAAOH,EAAS,IAAK,EAEtCM,EAAKP,EAAMG,EAAMC,EAAOC,CAAK,CAE/B,OAAUG,EAAM,CACf,OAAOA,CACR,CACA,OAAOD,CACR,CAKAR,EAAO,QAAUG,ICjBjB,IAAIO,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAO,IAKXF,EAAaC,EAAM,OAAQC,CAAK,EAKhC,OAAO,QAAUD", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_main", "__commonJSMin", "exports", "module", "op", "defaults", "open", "path", "flags", "mode", "clbk", "nargs", "require_sync", "__commonJSMin", "exports", "module", "open", "defaults", "openSync", "path", "flags", "mode", "nargs", "fd", "err", "setReadOnly", "main", "sync"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4cbf7ac..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,65 +0,0 @@ - -{{alias}}( path[, flags[, mode]], clbk ) - Asynchronously opens a file. - - Some characters, such as <>:"/\|?*, are reserved under Windows. - Under NTFS, if the path contains a colon, Node.js will open a file system - stream. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - clbk: Function - Callback to invoke upon opening a file. - - Examples - -------- - > function onOpen( error, fd ) { - ... if ( error ) { - ... console.error( error.message ); - ... } else { - ... {{alias:@stdlib/fs/close}}.sync( fd ); - ... } - ... }; - > {{alias}}( './beep/boop.txt', onOpen ); - - -{{alias}}.sync( path[, flags[, mode]] ) - Synchronously opens a file. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - Returns - ------- - fd: Error|integer - File descriptor. - - Examples - -------- - > var fd = {{alias}}.sync( './beep/boop.txt' ); - > if ( !{{alias:@stdlib/assert/is-error}}( fd ) ) { {{alias:@stdlib/fs/close}}.sync( fd ); }; - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 67907a2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,129 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 open = require( './index' ); - -const done = ( error: Error, fd: number ) => { - if ( error || !fd ) { - throw error; - } -}; - - -// TESTS // - -// The function does not have a return value... -{ - open( '/path/to/beepboop', done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a string... -{ - open( 123, done ); // $ExpectError - open( false, done ); // $ExpectError - open( true, done ); // $ExpectError - open( null, done ); // $ExpectError - open( undefined, done ); // $ExpectError - open( [], done ); // $ExpectError - open( {}, done ); // $ExpectError - open( ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a last argument which is not a function with the expected signature... -{ - open( '/path/to/beepboop', 'abc' ); // $ExpectError - open( '/path/to/beepboop', 123 ); // $ExpectError - open( '/path/to/beepboop', false ); // $ExpectError - open( '/path/to/beepboop', true ); // $ExpectError - open( '/path/to/beepboop', null ); // $ExpectError - open( '/path/to/beepboop', undefined ); // $ExpectError - open( '/path/to/beepboop', [] ); // $ExpectError - open( '/path/to/beepboop', {} ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `flags` argument which is not a string or number... -{ - open( '/path/to/beepboop', false, done ); // $ExpectError - open( '/path/to/beepboop', true, done ); // $ExpectError - open( '/path/to/beepboop', null, done ); // $ExpectError - open( '/path/to/beepboop', undefined, done ); // $ExpectError - open( '/path/to/beepboop', [], done ); // $ExpectError - open( '/path/to/beepboop', {}, done ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` argument which is not a number... -{ - open( '/path/to/beepboop', 'r+', 'abc', done ); // $ExpectError - open( '/path/to/beepboop', 'r+', false, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', true, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', null, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', undefined, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', [], done ); // $ExpectError - open( '/path/to/beepboop', 'r+', {}, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - open(); // $ExpectError - open( 'C:\\foo\\bar\\baz' ); // $ExpectError -} - -// Attached to main export is a `sync` method which returns a number or an error... -{ - open.sync( '/path/to/beepboop' ); // $ExpectType number | Error -} - -// The compiler throws an error if the `sync` method is provided a first argument which is not a string... -{ - open.sync( 123 ); // $ExpectError - open.sync( false ); // $ExpectError - open.sync( true ); // $ExpectError - open.sync( null ); // $ExpectError - open.sync( undefined ); // $ExpectError - open.sync( [] ); // $ExpectError - open.sync( {} ); // $ExpectError - open.sync( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a second argument which is not a string or number... -{ - open.sync( '/path/to/beepboop', false ); // $ExpectError - open.sync( '/path/to/beepboop', true ); // $ExpectError - open.sync( '/path/to/beepboop', null ); // $ExpectError - open.sync( '/path/to/beepboop', [] ); // $ExpectError - open.sync( '/path/to/beepboop', {} ); // $ExpectError - open.sync( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a third argument which is not a number... -{ - open.sync( '/path/to/beepboop', 'r+', false ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', true ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', null ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', [] ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', {} ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided an unsupported number of arguments... -{ - open.sync(); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 71359fe..0000000 --- a/examples/index.js +++ /dev/null @@ -1,56 +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. -*/ - -'use strict'; - -var closeSync = require( '@stdlib/fs-close' ).sync; -var isError = require( '@stdlib/assert-is-error' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - -/* Sync */ - -var fd = open.sync( __filename, 'r+' ); -// returns - -console.log( isError( fd ) ); -// => false - -closeSync( fd ); - -fd = open.sync( 'beepboop' ); -// returns - -console.log( isError( fd ) ); -// => true - -/* Async */ - -open( __filename, onOpen ); -open( 'beepboop', onOpen ); - -function onOpen( error, fd ) { - if ( error ) { - if ( error.code === 'ENOENT' ) { - console.error( 'File does not exist.' ); - } else { - throw error; - } - } else { - closeSync( fd ); - } -} 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..9e3afbc --- /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/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var r=t(Object.freeze({__proto__:null,default:{}})),n="r",o=438,c=r.open;function u(e,t,r,u){var i=arguments.length;return 2===i?c(e,n,o,t):3===i?c(e,t,o,r):void c(e,t,r,u)}var i=r.openSync;function s(e,t,r){var c,u;c=arguments.length;try{u=1===c?i(e,n,o):i(e,t,2===c?o:r)}catch(e){return e}return u}e(u,"sync",s);export{u as default,s as sync}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..0d9f33f --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;0nBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAEzB,CAAC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index cb174b7..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "flags": "r", - "mode": 438 -} diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 8edd6de..0000000 --- a/lib/index.js +++ /dev/null @@ -1,63 +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. -*/ - -'use strict'; - -/** -* Open a file. -* -* @module @stdlib/fs-open -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var openSync = require( '@stdlib/fs-open' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var sync = require( './sync.js' ); - - -// MAIN // - -setReadOnly( main, 'sync', sync ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index feb5171..0000000 --- a/lib/main.js +++ /dev/null @@ -1,64 +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. -*/ - -'use strict'; - -// MODULES // - -var op = require( 'fs' ).open; -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Asynchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @param {Function} clbk - callback to invoke after opening a file -* @returns {void} -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -*/ -function open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare - var nargs = arguments.length; - if ( nargs === 2 ) { - return op( path, defaults.flags, defaults.mode, flags ); - } - if ( nargs === 3 ) { - return op( path, flags, defaults.mode, mode ); - } - op( path, flags, mode, clbk ); -} - - -// EXPORTS // - -module.exports = open; diff --git a/lib/sync.js b/lib/sync.js deleted file mode 100644 index d8d2e00..0000000 --- a/lib/sync.js +++ /dev/null @@ -1,68 +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. -*/ - -'use strict'; - -// MODULES // - -var open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Synchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @returns {(integer|Error)} file descriptor or an error -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -function openSync( path, flags, mode ) { - var nargs; - var fd; - - nargs = arguments.length; - try { - if ( nargs === 1 ) { - fd = open( path, defaults.flags, defaults.mode ); - } else if ( nargs === 2 ) { - fd = open( path, flags, defaults.mode ); - } else { - fd = open( path, flags, mode ); - } - } catch ( err ) { - return err; - } - return fd; -} - - -// EXPORTS // - -module.exports = openSync; diff --git a/package.json b/package.json index b373e1d..b313f37 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Open a file.", "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/utils-define-nonenumerable-read-only-property": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.2.1", - "@stdlib/assert-is-error": "^0.2.1", - "@stdlib/assert-is-nonnegative-integer": "^0.2.1", - "@stdlib/fs-close": "^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", "stdfs", @@ -82,4 +30,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..34bd866 --- /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 3c47135..0000000 --- a/test/test.js +++ /dev/null @@ -1,38 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is a function to open a file synchronously', function test( t ) { - t.equal( typeof open.sync, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 33b938f..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,110 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/main.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - open( __filename, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - open( __filename, 'r+', onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - open( __filename, 'r+', 438, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - open( 'beepboopbapbop', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', 438, onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); diff --git a/test/test.sync.js b/test/test.sync.js deleted file mode 100644 index 56d7b23..0000000 --- a/test/test.sync.js +++ /dev/null @@ -1,83 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/sync.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - var fd = open( __filename ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - var fd = open( __filename, 'r+' ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - var fd = open( __filename, 'r+', 438 ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - var fd = open( 'beepboopbapbop' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+', 438 ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); From efc214de9ea3ceff679c6ce707bc28cbf4207bae Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 00:50:13 +0000 Subject: [PATCH 076/113] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 8dbf5e0..b373e1d 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.2.1", @@ -81,4 +82,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From a8b9156c66f278ac683c2ea2b24b0d33bfd08cf0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 01:30:13 +0000 Subject: [PATCH 077/113] Remove files --- index.d.ts | 150 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4997 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 dddbd0c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,150 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Buffer } from 'buffer'; - -/** -* Callback invoked after opening a file. -* -* @param err - error argument -* @param fd - file descriptor -*/ -type Callback = ( err: Error, fd: number ) => void; - -/** -* Interface for opening a file. -*/ -interface Open { - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', 438, onOpen ); - */ - ( path: string | Buffer, flags: string | number, mode: number, clbk: Callback ): void; - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', onOpen ); - */ - ( path: string | Buffer, flags: string | number, clbk: Callback ): void; - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, onOpen ); - */ - ( path: string | Buffer, clbk: Callback ): void; - - /** - * Synchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @returns file descriptor or an error - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * var fd = open.sync( __filename, 'r+' ); - * if ( fd instanceof Error ) { - * throw fd; - * } - * closeSync( fd ); - */ - sync( path: string | Buffer, flags?: string | number, mode?: number ): number | Error; -} - -/** -* Asynchronously opens a file. -* -* @param path - file path -* @param flags - file system flags (default: 'r') -* @param mode - file mode (default: 0o666) -* @param clbk - callback to invoke after opening a file -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* var fd = open.sync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -declare var open: Open; - - -// EXPORTS // - -export = open; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 9e3afbc..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/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var r=t(Object.freeze({__proto__:null,default:{}})),n="r",o=438,c=r.open;function u(e,t,r,u){var i=arguments.length;return 2===i?c(e,n,o,t):3===i?c(e,t,o,r):void c(e,t,r,u)}var i=r.openSync;function s(e,t,r){var c,u;c=arguments.length;try{u=1===c?i(e,n,o):i(e,t,2===c?o:r)}catch(e){return e}return u}e(u,"sync",s);export{u as default,s as sync}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 0d9f33f..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;0nBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAEzB,CAAC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 34bd866..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 594ad277b0a8819889bdfba801a0cefcdb5a43d3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 01:30:22 +0000 Subject: [PATCH 078/113] 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 | 55 +- SECURITY.md | 5 - benchmark/benchmark.js | 77 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 65 - docs/types/test.ts | 129 - examples/index.js | 56 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/defaults.json | 4 - lib/index.js | 63 - lib/main.js | 64 - lib/sync.js | 68 - package.json | 58 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 38 - test/test.main.js | 110 - test/test.sync.js | 83 - 47 files changed, 4876 insertions(+), 4118 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/defaults.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/sync.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.sync.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 b4041bc..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-04-01T00:42:28.254Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index a3a4470..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/fs/open) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 7617ad3..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/fs/open) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 d7fc8a0..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: '14 2 * * 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 + + ```
@@ -225,7 +222,7 @@ function onOpen( error, fd ) { ## 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]. @@ -292,11 +289,11 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close +[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close/tree/esm -[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists +[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists/tree/esm -[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file +[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file/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 503cc81..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,77 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var closeSync = require( '@stdlib/fs-close' ).sync; -var pkg = require( './../package.json' ).name; -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return open( __filename, 'r+', done ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function done( error, fd ) { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - if ( error ) { - b.fail( error.message ); - } - next(); - } -}); - -bench( pkg+':sync', function benchmark( b ) { - var fd; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - fd = open.sync( __filename, 'r+' ); - if ( fd instanceof Error ) { - b.fail( fd.message ); - } else { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - } - } - b.toc(); - if ( fd instanceof Error ) { - b.fail( 'something went wrong' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index da1ba5f..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/fs/open" -%% click B href "https://github.com/stdlib-js/fs-open/tree/main" -%% click C href "https://github.com/stdlib-js/fs-open/tree/production" -%% click D href "https://github.com/stdlib-js/fs-open/tree/esm" -%% click E href "https://github.com/stdlib-js/fs-open/tree/deno" -%% click F href "https://github.com/stdlib-js/fs-open/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/fs/open -[production-url]: https://github.com/stdlib-js/fs-open/tree/production -[deno-url]: https://github.com/stdlib-js/fs-open/tree/deno -[deno-readme]: https://github.com/stdlib-js/fs-open/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/fs-open/tree/umd -[umd-readme]: https://github.com/stdlib-js/fs-open/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/fs-open/tree/esm -[esm-readme]: https://github.com/stdlib-js/fs-open/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 3e10601..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import open from '../docs/types/index'; -export = open; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 5358415..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var u=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var i=u(function(b,y){y.exports={flags:"r",mode:438}});var d=u(function(j,f){ -var a=require("fs").open,o=i();function p(r,e,t,s){var n=arguments.length;if(n===2)return a(r,o.flags,o.mode,e);if(n===3)return a(r,e,o.mode,t);a(r,e,t,s)}f.exports=p -});var m=u(function(k,l){ -var c=require("fs").openSync,v=i();function x(r,e,t){var s,n;s=arguments.length;try{s===1?n=c(r,v.flags,v.mode):s===2?n=c(r,e,v.mode):n=c(r,e,t)}catch(g){return g}return n}l.exports=x -});var S=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),q=d(),O=m();S(q,"sync",O);module.exports=q; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 65b6278..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/main.js", "../lib/sync.js", "../lib/index.js"], - "sourcesContent": ["{\n\t\"flags\": \"r\",\n\t\"mode\": 438\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var open = require( '@stdlib/fs-open' );\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nmodule.exports = open;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nmodule.exports = openSync;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var open = require( '@stdlib/fs-open' );\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var openSync = require( '@stdlib/fs-open' ).sync;\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar sync = require( './sync.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,CAAAA,EAAA,SACC,MAAS,IACT,KAAQ,GACT,ICHA,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAK,QAAS,IAAK,EAAE,KACrBC,EAAW,IA0Bf,SAASC,EAAMC,EAAMC,EAAOC,EAAMC,EAAO,CACxC,IAAIC,EAAQ,UAAU,OACtB,GAAKA,IAAU,EACd,OAAOP,EAAIG,EAAMF,EAAS,MAAOA,EAAS,KAAMG,CAAM,EAEvD,GAAKG,IAAU,EACd,OAAOP,EAAIG,EAAMC,EAAOH,EAAS,KAAMI,CAAK,EAE7CL,EAAIG,EAAMC,EAAOC,EAAMC,CAAK,CAC7B,CAKAP,EAAO,QAAUG,IC/DjB,IAAAM,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAO,QAAS,IAAK,EAAE,SACvBC,EAAW,IAsBf,SAASC,EAAUC,EAAMC,EAAOC,EAAO,CACtC,IAAIC,EACAC,EAEJD,EAAQ,UAAU,OAClB,GAAI,CACEA,IAAU,EACdC,EAAKP,EAAMG,EAAMF,EAAS,MAAOA,EAAS,IAAK,EACpCK,IAAU,EACrBC,EAAKP,EAAMG,EAAMC,EAAOH,EAAS,IAAK,EAEtCM,EAAKP,EAAMG,EAAMC,EAAOC,CAAK,CAE/B,OAAUG,EAAM,CACf,OAAOA,CACR,CACA,OAAOD,CACR,CAKAR,EAAO,QAAUG,ICjBjB,IAAIO,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAO,IAKXF,EAAaC,EAAM,OAAQC,CAAK,EAKhC,OAAO,QAAUD", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_main", "__commonJSMin", "exports", "module", "op", "defaults", "open", "path", "flags", "mode", "clbk", "nargs", "require_sync", "__commonJSMin", "exports", "module", "open", "defaults", "openSync", "path", "flags", "mode", "nargs", "fd", "err", "setReadOnly", "main", "sync"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4cbf7ac..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,65 +0,0 @@ - -{{alias}}( path[, flags[, mode]], clbk ) - Asynchronously opens a file. - - Some characters, such as <>:"/\|?*, are reserved under Windows. - Under NTFS, if the path contains a colon, Node.js will open a file system - stream. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - clbk: Function - Callback to invoke upon opening a file. - - Examples - -------- - > function onOpen( error, fd ) { - ... if ( error ) { - ... console.error( error.message ); - ... } else { - ... {{alias:@stdlib/fs/close}}.sync( fd ); - ... } - ... }; - > {{alias}}( './beep/boop.txt', onOpen ); - - -{{alias}}.sync( path[, flags[, mode]] ) - Synchronously opens a file. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - Returns - ------- - fd: Error|integer - File descriptor. - - Examples - -------- - > var fd = {{alias}}.sync( './beep/boop.txt' ); - > if ( !{{alias:@stdlib/assert/is-error}}( fd ) ) { {{alias:@stdlib/fs/close}}.sync( fd ); }; - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 67907a2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,129 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 open = require( './index' ); - -const done = ( error: Error, fd: number ) => { - if ( error || !fd ) { - throw error; - } -}; - - -// TESTS // - -// The function does not have a return value... -{ - open( '/path/to/beepboop', done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a string... -{ - open( 123, done ); // $ExpectError - open( false, done ); // $ExpectError - open( true, done ); // $ExpectError - open( null, done ); // $ExpectError - open( undefined, done ); // $ExpectError - open( [], done ); // $ExpectError - open( {}, done ); // $ExpectError - open( ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a last argument which is not a function with the expected signature... -{ - open( '/path/to/beepboop', 'abc' ); // $ExpectError - open( '/path/to/beepboop', 123 ); // $ExpectError - open( '/path/to/beepboop', false ); // $ExpectError - open( '/path/to/beepboop', true ); // $ExpectError - open( '/path/to/beepboop', null ); // $ExpectError - open( '/path/to/beepboop', undefined ); // $ExpectError - open( '/path/to/beepboop', [] ); // $ExpectError - open( '/path/to/beepboop', {} ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `flags` argument which is not a string or number... -{ - open( '/path/to/beepboop', false, done ); // $ExpectError - open( '/path/to/beepboop', true, done ); // $ExpectError - open( '/path/to/beepboop', null, done ); // $ExpectError - open( '/path/to/beepboop', undefined, done ); // $ExpectError - open( '/path/to/beepboop', [], done ); // $ExpectError - open( '/path/to/beepboop', {}, done ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` argument which is not a number... -{ - open( '/path/to/beepboop', 'r+', 'abc', done ); // $ExpectError - open( '/path/to/beepboop', 'r+', false, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', true, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', null, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', undefined, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', [], done ); // $ExpectError - open( '/path/to/beepboop', 'r+', {}, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - open(); // $ExpectError - open( 'C:\\foo\\bar\\baz' ); // $ExpectError -} - -// Attached to main export is a `sync` method which returns a number or an error... -{ - open.sync( '/path/to/beepboop' ); // $ExpectType number | Error -} - -// The compiler throws an error if the `sync` method is provided a first argument which is not a string... -{ - open.sync( 123 ); // $ExpectError - open.sync( false ); // $ExpectError - open.sync( true ); // $ExpectError - open.sync( null ); // $ExpectError - open.sync( undefined ); // $ExpectError - open.sync( [] ); // $ExpectError - open.sync( {} ); // $ExpectError - open.sync( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a second argument which is not a string or number... -{ - open.sync( '/path/to/beepboop', false ); // $ExpectError - open.sync( '/path/to/beepboop', true ); // $ExpectError - open.sync( '/path/to/beepboop', null ); // $ExpectError - open.sync( '/path/to/beepboop', [] ); // $ExpectError - open.sync( '/path/to/beepboop', {} ); // $ExpectError - open.sync( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a third argument which is not a number... -{ - open.sync( '/path/to/beepboop', 'r+', false ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', true ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', null ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', [] ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', {} ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided an unsupported number of arguments... -{ - open.sync(); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 71359fe..0000000 --- a/examples/index.js +++ /dev/null @@ -1,56 +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. -*/ - -'use strict'; - -var closeSync = require( '@stdlib/fs-close' ).sync; -var isError = require( '@stdlib/assert-is-error' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - -/* Sync */ - -var fd = open.sync( __filename, 'r+' ); -// returns - -console.log( isError( fd ) ); -// => false - -closeSync( fd ); - -fd = open.sync( 'beepboop' ); -// returns - -console.log( isError( fd ) ); -// => true - -/* Async */ - -open( __filename, onOpen ); -open( 'beepboop', onOpen ); - -function onOpen( error, fd ) { - if ( error ) { - if ( error.code === 'ENOENT' ) { - console.error( 'File does not exist.' ); - } else { - throw error; - } - } else { - closeSync( fd ); - } -} 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..9e3afbc --- /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/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var r=t(Object.freeze({__proto__:null,default:{}})),n="r",o=438,c=r.open;function u(e,t,r,u){var i=arguments.length;return 2===i?c(e,n,o,t):3===i?c(e,t,o,r):void c(e,t,r,u)}var i=r.openSync;function s(e,t,r){var c,u;c=arguments.length;try{u=1===c?i(e,n,o):i(e,t,2===c?o:r)}catch(e){return e}return u}e(u,"sync",s);export{u as default,s as sync}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..0d9f33f --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;0nBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAEzB,CAAC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index cb174b7..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "flags": "r", - "mode": 438 -} diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 8edd6de..0000000 --- a/lib/index.js +++ /dev/null @@ -1,63 +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. -*/ - -'use strict'; - -/** -* Open a file. -* -* @module @stdlib/fs-open -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var openSync = require( '@stdlib/fs-open' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var sync = require( './sync.js' ); - - -// MAIN // - -setReadOnly( main, 'sync', sync ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index feb5171..0000000 --- a/lib/main.js +++ /dev/null @@ -1,64 +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. -*/ - -'use strict'; - -// MODULES // - -var op = require( 'fs' ).open; -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Asynchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @param {Function} clbk - callback to invoke after opening a file -* @returns {void} -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -*/ -function open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare - var nargs = arguments.length; - if ( nargs === 2 ) { - return op( path, defaults.flags, defaults.mode, flags ); - } - if ( nargs === 3 ) { - return op( path, flags, defaults.mode, mode ); - } - op( path, flags, mode, clbk ); -} - - -// EXPORTS // - -module.exports = open; diff --git a/lib/sync.js b/lib/sync.js deleted file mode 100644 index d8d2e00..0000000 --- a/lib/sync.js +++ /dev/null @@ -1,68 +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. -*/ - -'use strict'; - -// MODULES // - -var open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Synchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @returns {(integer|Error)} file descriptor or an error -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -function openSync( path, flags, mode ) { - var nargs; - var fd; - - nargs = arguments.length; - try { - if ( nargs === 1 ) { - fd = open( path, defaults.flags, defaults.mode ); - } else if ( nargs === 2 ) { - fd = open( path, flags, defaults.mode ); - } else { - fd = open( path, flags, mode ); - } - } catch ( err ) { - return err; - } - return fd; -} - - -// EXPORTS // - -module.exports = openSync; diff --git a/package.json b/package.json index b373e1d..b313f37 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Open a file.", "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/utils-define-nonenumerable-read-only-property": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.2.1", - "@stdlib/assert-is-error": "^0.2.1", - "@stdlib/assert-is-nonnegative-integer": "^0.2.1", - "@stdlib/fs-close": "^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", "stdfs", @@ -82,4 +30,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..34bd866 --- /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 3c47135..0000000 --- a/test/test.js +++ /dev/null @@ -1,38 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is a function to open a file synchronously', function test( t ) { - t.equal( typeof open.sync, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 33b938f..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,110 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/main.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - open( __filename, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - open( __filename, 'r+', onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - open( __filename, 'r+', 438, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - open( 'beepboopbapbop', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', 438, onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); diff --git a/test/test.sync.js b/test/test.sync.js deleted file mode 100644 index 56d7b23..0000000 --- a/test/test.sync.js +++ /dev/null @@ -1,83 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/sync.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - var fd = open( __filename ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - var fd = open( __filename, 'r+' ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - var fd = open( __filename, 'r+', 438 ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - var fd = open( 'beepboopbapbop' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+', 438 ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); From a1324259231f7fe052ad2297dbaca438ed316096 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 11 Apr 2024 20:59:06 +0000 Subject: [PATCH 079/113] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 8dbf5e0..b373e1d 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.2.1", @@ -81,4 +82,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 37f419c212267589081c22b557b387168d8945c0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 11 Apr 2024 21:28:31 +0000 Subject: [PATCH 080/113] Remove files --- index.d.ts | 150 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4997 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 dddbd0c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,150 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Buffer } from 'buffer'; - -/** -* Callback invoked after opening a file. -* -* @param err - error argument -* @param fd - file descriptor -*/ -type Callback = ( err: Error, fd: number ) => void; - -/** -* Interface for opening a file. -*/ -interface Open { - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', 438, onOpen ); - */ - ( path: string | Buffer, flags: string | number, mode: number, clbk: Callback ): void; - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', onOpen ); - */ - ( path: string | Buffer, flags: string | number, clbk: Callback ): void; - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, onOpen ); - */ - ( path: string | Buffer, clbk: Callback ): void; - - /** - * Synchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @returns file descriptor or an error - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * var fd = open.sync( __filename, 'r+' ); - * if ( fd instanceof Error ) { - * throw fd; - * } - * closeSync( fd ); - */ - sync( path: string | Buffer, flags?: string | number, mode?: number ): number | Error; -} - -/** -* Asynchronously opens a file. -* -* @param path - file path -* @param flags - file system flags (default: 'r') -* @param mode - file mode (default: 0o666) -* @param clbk - callback to invoke after opening a file -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* var fd = open.sync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -declare var open: Open; - - -// EXPORTS // - -export = open; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 9e3afbc..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/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var r=t(Object.freeze({__proto__:null,default:{}})),n="r",o=438,c=r.open;function u(e,t,r,u){var i=arguments.length;return 2===i?c(e,n,o,t):3===i?c(e,t,o,r):void c(e,t,r,u)}var i=r.openSync;function s(e,t,r){var c,u;c=arguments.length;try{u=1===c?i(e,n,o):i(e,t,2===c?o:r)}catch(e){return e}return u}e(u,"sync",s);export{u as default,s as sync}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 0d9f33f..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;0nBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAEzB,CAAC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 34bd866..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From f22409206d8e38c37c99f03f038e94b08c5c9a18 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 11 Apr 2024 21:28:45 +0000 Subject: [PATCH 081/113] 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 | 55 +- SECURITY.md | 5 - benchmark/benchmark.js | 77 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 65 - docs/types/test.ts | 129 - examples/index.js | 56 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/defaults.json | 4 - lib/index.js | 63 - lib/main.js | 64 - lib/sync.js | 68 - package.json | 58 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 38 - test/test.main.js | 110 - test/test.sync.js | 83 - 46 files changed, 4876 insertions(+), 4119 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/defaults.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/sync.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.sync.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 a3a4470..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/fs/open) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 7617ad3..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/fs/open) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 d7fc8a0..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: '14 2 * * 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 + + ```
@@ -225,7 +222,7 @@ function onOpen( error, fd ) { ## 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]. @@ -292,11 +289,11 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close +[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close/tree/esm -[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists +[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists/tree/esm -[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file +[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file/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 503cc81..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,77 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var closeSync = require( '@stdlib/fs-close' ).sync; -var pkg = require( './../package.json' ).name; -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return open( __filename, 'r+', done ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function done( error, fd ) { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - if ( error ) { - b.fail( error.message ); - } - next(); - } -}); - -bench( pkg+':sync', function benchmark( b ) { - var fd; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - fd = open.sync( __filename, 'r+' ); - if ( fd instanceof Error ) { - b.fail( fd.message ); - } else { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - } - } - b.toc(); - if ( fd instanceof Error ) { - b.fail( 'something went wrong' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index da1ba5f..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/fs/open" -%% click B href "https://github.com/stdlib-js/fs-open/tree/main" -%% click C href "https://github.com/stdlib-js/fs-open/tree/production" -%% click D href "https://github.com/stdlib-js/fs-open/tree/esm" -%% click E href "https://github.com/stdlib-js/fs-open/tree/deno" -%% click F href "https://github.com/stdlib-js/fs-open/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/fs/open -[production-url]: https://github.com/stdlib-js/fs-open/tree/production -[deno-url]: https://github.com/stdlib-js/fs-open/tree/deno -[deno-readme]: https://github.com/stdlib-js/fs-open/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/fs-open/tree/umd -[umd-readme]: https://github.com/stdlib-js/fs-open/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/fs-open/tree/esm -[esm-readme]: https://github.com/stdlib-js/fs-open/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 3e10601..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import open from '../docs/types/index'; -export = open; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 5358415..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var u=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var i=u(function(b,y){y.exports={flags:"r",mode:438}});var d=u(function(j,f){ -var a=require("fs").open,o=i();function p(r,e,t,s){var n=arguments.length;if(n===2)return a(r,o.flags,o.mode,e);if(n===3)return a(r,e,o.mode,t);a(r,e,t,s)}f.exports=p -});var m=u(function(k,l){ -var c=require("fs").openSync,v=i();function x(r,e,t){var s,n;s=arguments.length;try{s===1?n=c(r,v.flags,v.mode):s===2?n=c(r,e,v.mode):n=c(r,e,t)}catch(g){return g}return n}l.exports=x -});var S=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),q=d(),O=m();S(q,"sync",O);module.exports=q; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 65b6278..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/main.js", "../lib/sync.js", "../lib/index.js"], - "sourcesContent": ["{\n\t\"flags\": \"r\",\n\t\"mode\": 438\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var open = require( '@stdlib/fs-open' );\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nmodule.exports = open;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nmodule.exports = openSync;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var open = require( '@stdlib/fs-open' );\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var openSync = require( '@stdlib/fs-open' ).sync;\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar sync = require( './sync.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,CAAAA,EAAA,SACC,MAAS,IACT,KAAQ,GACT,ICHA,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAK,QAAS,IAAK,EAAE,KACrBC,EAAW,IA0Bf,SAASC,EAAMC,EAAMC,EAAOC,EAAMC,EAAO,CACxC,IAAIC,EAAQ,UAAU,OACtB,GAAKA,IAAU,EACd,OAAOP,EAAIG,EAAMF,EAAS,MAAOA,EAAS,KAAMG,CAAM,EAEvD,GAAKG,IAAU,EACd,OAAOP,EAAIG,EAAMC,EAAOH,EAAS,KAAMI,CAAK,EAE7CL,EAAIG,EAAMC,EAAOC,EAAMC,CAAK,CAC7B,CAKAP,EAAO,QAAUG,IC/DjB,IAAAM,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAO,QAAS,IAAK,EAAE,SACvBC,EAAW,IAsBf,SAASC,EAAUC,EAAMC,EAAOC,EAAO,CACtC,IAAIC,EACAC,EAEJD,EAAQ,UAAU,OAClB,GAAI,CACEA,IAAU,EACdC,EAAKP,EAAMG,EAAMF,EAAS,MAAOA,EAAS,IAAK,EACpCK,IAAU,EACrBC,EAAKP,EAAMG,EAAMC,EAAOH,EAAS,IAAK,EAEtCM,EAAKP,EAAMG,EAAMC,EAAOC,CAAK,CAE/B,OAAUG,EAAM,CACf,OAAOA,CACR,CACA,OAAOD,CACR,CAKAR,EAAO,QAAUG,ICjBjB,IAAIO,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAO,IAKXF,EAAaC,EAAM,OAAQC,CAAK,EAKhC,OAAO,QAAUD", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_main", "__commonJSMin", "exports", "module", "op", "defaults", "open", "path", "flags", "mode", "clbk", "nargs", "require_sync", "__commonJSMin", "exports", "module", "open", "defaults", "openSync", "path", "flags", "mode", "nargs", "fd", "err", "setReadOnly", "main", "sync"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4cbf7ac..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,65 +0,0 @@ - -{{alias}}( path[, flags[, mode]], clbk ) - Asynchronously opens a file. - - Some characters, such as <>:"/\|?*, are reserved under Windows. - Under NTFS, if the path contains a colon, Node.js will open a file system - stream. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - clbk: Function - Callback to invoke upon opening a file. - - Examples - -------- - > function onOpen( error, fd ) { - ... if ( error ) { - ... console.error( error.message ); - ... } else { - ... {{alias:@stdlib/fs/close}}.sync( fd ); - ... } - ... }; - > {{alias}}( './beep/boop.txt', onOpen ); - - -{{alias}}.sync( path[, flags[, mode]] ) - Synchronously opens a file. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - Returns - ------- - fd: Error|integer - File descriptor. - - Examples - -------- - > var fd = {{alias}}.sync( './beep/boop.txt' ); - > if ( !{{alias:@stdlib/assert/is-error}}( fd ) ) { {{alias:@stdlib/fs/close}}.sync( fd ); }; - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 67907a2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,129 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 open = require( './index' ); - -const done = ( error: Error, fd: number ) => { - if ( error || !fd ) { - throw error; - } -}; - - -// TESTS // - -// The function does not have a return value... -{ - open( '/path/to/beepboop', done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a string... -{ - open( 123, done ); // $ExpectError - open( false, done ); // $ExpectError - open( true, done ); // $ExpectError - open( null, done ); // $ExpectError - open( undefined, done ); // $ExpectError - open( [], done ); // $ExpectError - open( {}, done ); // $ExpectError - open( ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a last argument which is not a function with the expected signature... -{ - open( '/path/to/beepboop', 'abc' ); // $ExpectError - open( '/path/to/beepboop', 123 ); // $ExpectError - open( '/path/to/beepboop', false ); // $ExpectError - open( '/path/to/beepboop', true ); // $ExpectError - open( '/path/to/beepboop', null ); // $ExpectError - open( '/path/to/beepboop', undefined ); // $ExpectError - open( '/path/to/beepboop', [] ); // $ExpectError - open( '/path/to/beepboop', {} ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `flags` argument which is not a string or number... -{ - open( '/path/to/beepboop', false, done ); // $ExpectError - open( '/path/to/beepboop', true, done ); // $ExpectError - open( '/path/to/beepboop', null, done ); // $ExpectError - open( '/path/to/beepboop', undefined, done ); // $ExpectError - open( '/path/to/beepboop', [], done ); // $ExpectError - open( '/path/to/beepboop', {}, done ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` argument which is not a number... -{ - open( '/path/to/beepboop', 'r+', 'abc', done ); // $ExpectError - open( '/path/to/beepboop', 'r+', false, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', true, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', null, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', undefined, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', [], done ); // $ExpectError - open( '/path/to/beepboop', 'r+', {}, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - open(); // $ExpectError - open( 'C:\\foo\\bar\\baz' ); // $ExpectError -} - -// Attached to main export is a `sync` method which returns a number or an error... -{ - open.sync( '/path/to/beepboop' ); // $ExpectType number | Error -} - -// The compiler throws an error if the `sync` method is provided a first argument which is not a string... -{ - open.sync( 123 ); // $ExpectError - open.sync( false ); // $ExpectError - open.sync( true ); // $ExpectError - open.sync( null ); // $ExpectError - open.sync( undefined ); // $ExpectError - open.sync( [] ); // $ExpectError - open.sync( {} ); // $ExpectError - open.sync( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a second argument which is not a string or number... -{ - open.sync( '/path/to/beepboop', false ); // $ExpectError - open.sync( '/path/to/beepboop', true ); // $ExpectError - open.sync( '/path/to/beepboop', null ); // $ExpectError - open.sync( '/path/to/beepboop', [] ); // $ExpectError - open.sync( '/path/to/beepboop', {} ); // $ExpectError - open.sync( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a third argument which is not a number... -{ - open.sync( '/path/to/beepboop', 'r+', false ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', true ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', null ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', [] ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', {} ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided an unsupported number of arguments... -{ - open.sync(); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 71359fe..0000000 --- a/examples/index.js +++ /dev/null @@ -1,56 +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. -*/ - -'use strict'; - -var closeSync = require( '@stdlib/fs-close' ).sync; -var isError = require( '@stdlib/assert-is-error' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - -/* Sync */ - -var fd = open.sync( __filename, 'r+' ); -// returns - -console.log( isError( fd ) ); -// => false - -closeSync( fd ); - -fd = open.sync( 'beepboop' ); -// returns - -console.log( isError( fd ) ); -// => true - -/* Async */ - -open( __filename, onOpen ); -open( 'beepboop', onOpen ); - -function onOpen( error, fd ) { - if ( error ) { - if ( error.code === 'ENOENT' ) { - console.error( 'File does not exist.' ); - } else { - throw error; - } - } else { - closeSync( fd ); - } -} 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..9e3afbc --- /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/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var r=t(Object.freeze({__proto__:null,default:{}})),n="r",o=438,c=r.open;function u(e,t,r,u){var i=arguments.length;return 2===i?c(e,n,o,t):3===i?c(e,t,o,r):void c(e,t,r,u)}var i=r.openSync;function s(e,t,r){var c,u;c=arguments.length;try{u=1===c?i(e,n,o):i(e,t,2===c?o:r)}catch(e){return e}return u}e(u,"sync",s);export{u as default,s as sync}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..0d9f33f --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;0nBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAEzB,CAAC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index cb174b7..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "flags": "r", - "mode": 438 -} diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 8edd6de..0000000 --- a/lib/index.js +++ /dev/null @@ -1,63 +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. -*/ - -'use strict'; - -/** -* Open a file. -* -* @module @stdlib/fs-open -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var openSync = require( '@stdlib/fs-open' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var sync = require( './sync.js' ); - - -// MAIN // - -setReadOnly( main, 'sync', sync ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index feb5171..0000000 --- a/lib/main.js +++ /dev/null @@ -1,64 +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. -*/ - -'use strict'; - -// MODULES // - -var op = require( 'fs' ).open; -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Asynchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @param {Function} clbk - callback to invoke after opening a file -* @returns {void} -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -*/ -function open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare - var nargs = arguments.length; - if ( nargs === 2 ) { - return op( path, defaults.flags, defaults.mode, flags ); - } - if ( nargs === 3 ) { - return op( path, flags, defaults.mode, mode ); - } - op( path, flags, mode, clbk ); -} - - -// EXPORTS // - -module.exports = open; diff --git a/lib/sync.js b/lib/sync.js deleted file mode 100644 index d8d2e00..0000000 --- a/lib/sync.js +++ /dev/null @@ -1,68 +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. -*/ - -'use strict'; - -// MODULES // - -var open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Synchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @returns {(integer|Error)} file descriptor or an error -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -function openSync( path, flags, mode ) { - var nargs; - var fd; - - nargs = arguments.length; - try { - if ( nargs === 1 ) { - fd = open( path, defaults.flags, defaults.mode ); - } else if ( nargs === 2 ) { - fd = open( path, flags, defaults.mode ); - } else { - fd = open( path, flags, mode ); - } - } catch ( err ) { - return err; - } - return fd; -} - - -// EXPORTS // - -module.exports = openSync; diff --git a/package.json b/package.json index b373e1d..b313f37 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Open a file.", "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/utils-define-nonenumerable-read-only-property": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.2.1", - "@stdlib/assert-is-error": "^0.2.1", - "@stdlib/assert-is-nonnegative-integer": "^0.2.1", - "@stdlib/fs-close": "^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", "stdfs", @@ -82,4 +30,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..34bd866 --- /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 3c47135..0000000 --- a/test/test.js +++ /dev/null @@ -1,38 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is a function to open a file synchronously', function test( t ) { - t.equal( typeof open.sync, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 33b938f..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,110 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/main.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - open( __filename, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - open( __filename, 'r+', onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - open( __filename, 'r+', 438, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - open( 'beepboopbapbop', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', 438, onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); diff --git a/test/test.sync.js b/test/test.sync.js deleted file mode 100644 index 56d7b23..0000000 --- a/test/test.sync.js +++ /dev/null @@ -1,83 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/sync.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - var fd = open( __filename ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - var fd = open( __filename, 'r+' ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - var fd = open( __filename, 'r+', 438 ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - var fd = open( 'beepboopbapbop' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+', 438 ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); From d5fb764bba785cf1c6c84b19a08d3ef013b8f7dc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 May 2024 00:49:35 +0000 Subject: [PATCH 082/113] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 8dbf5e0..b373e1d 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.2.1", @@ -81,4 +82,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 39ca8dcf60b91a0b790c39fb830184a7bb272cb4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 May 2024 01:22:09 +0000 Subject: [PATCH 083/113] Remove files --- index.d.ts | 150 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4997 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 dddbd0c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,150 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Buffer } from 'buffer'; - -/** -* Callback invoked after opening a file. -* -* @param err - error argument -* @param fd - file descriptor -*/ -type Callback = ( err: Error, fd: number ) => void; - -/** -* Interface for opening a file. -*/ -interface Open { - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', 438, onOpen ); - */ - ( path: string | Buffer, flags: string | number, mode: number, clbk: Callback ): void; - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', onOpen ); - */ - ( path: string | Buffer, flags: string | number, clbk: Callback ): void; - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, onOpen ); - */ - ( path: string | Buffer, clbk: Callback ): void; - - /** - * Synchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @returns file descriptor or an error - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * var fd = open.sync( __filename, 'r+' ); - * if ( fd instanceof Error ) { - * throw fd; - * } - * closeSync( fd ); - */ - sync( path: string | Buffer, flags?: string | number, mode?: number ): number | Error; -} - -/** -* Asynchronously opens a file. -* -* @param path - file path -* @param flags - file system flags (default: 'r') -* @param mode - file mode (default: 0o666) -* @param clbk - callback to invoke after opening a file -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* var fd = open.sync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -declare var open: Open; - - -// EXPORTS // - -export = open; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 9e3afbc..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/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var r=t(Object.freeze({__proto__:null,default:{}})),n="r",o=438,c=r.open;function u(e,t,r,u){var i=arguments.length;return 2===i?c(e,n,o,t):3===i?c(e,t,o,r):void c(e,t,r,u)}var i=r.openSync;function s(e,t,r){var c,u;c=arguments.length;try{u=1===c?i(e,n,o):i(e,t,2===c?o:r)}catch(e){return e}return u}e(u,"sync",s);export{u as default,s as sync}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 0d9f33f..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;0nBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAEzB,CAAC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 34bd866..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 03a556e8acc98e36eb5b88d5aacb4ca3937e9f52 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 May 2024 01:22:26 +0000 Subject: [PATCH 084/113] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 248 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 55 +- SECURITY.md | 5 - benchmark/benchmark.js | 77 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 65 - docs/types/test.ts | 129 - examples/index.js | 56 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/defaults.json | 4 - lib/index.js | 63 - lib/main.js | 64 - lib/sync.js | 68 - package.json | 58 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 38 - test/test.main.js | 110 - test/test.sync.js | 83 - 47 files changed, 4876 insertions(+), 4127 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/defaults.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/sync.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.sync.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 b16c58c..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-05-01T00:41:29.824Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index a3a4470..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/fs/open) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 7617ad3..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/fs/open) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 d7fc8a0..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: '14 2 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f92a6c5..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -225,7 +222,7 @@ function onOpen( error, fd ) { ## 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]. @@ -292,11 +289,11 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close +[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close/tree/esm -[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists +[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists/tree/esm -[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file +[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file/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 503cc81..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,77 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var closeSync = require( '@stdlib/fs-close' ).sync; -var pkg = require( './../package.json' ).name; -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return open( __filename, 'r+', done ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function done( error, fd ) { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - if ( error ) { - b.fail( error.message ); - } - next(); - } -}); - -bench( pkg+':sync', function benchmark( b ) { - var fd; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - fd = open.sync( __filename, 'r+' ); - if ( fd instanceof Error ) { - b.fail( fd.message ); - } else { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - } - } - b.toc(); - if ( fd instanceof Error ) { - b.fail( 'something went wrong' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index da1ba5f..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/fs/open" -%% click B href "https://github.com/stdlib-js/fs-open/tree/main" -%% click C href "https://github.com/stdlib-js/fs-open/tree/production" -%% click D href "https://github.com/stdlib-js/fs-open/tree/esm" -%% click E href "https://github.com/stdlib-js/fs-open/tree/deno" -%% click F href "https://github.com/stdlib-js/fs-open/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/fs/open -[production-url]: https://github.com/stdlib-js/fs-open/tree/production -[deno-url]: https://github.com/stdlib-js/fs-open/tree/deno -[deno-readme]: https://github.com/stdlib-js/fs-open/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/fs-open/tree/umd -[umd-readme]: https://github.com/stdlib-js/fs-open/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/fs-open/tree/esm -[esm-readme]: https://github.com/stdlib-js/fs-open/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 3e10601..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import open from '../docs/types/index'; -export = open; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 5358415..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var u=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var i=u(function(b,y){y.exports={flags:"r",mode:438}});var d=u(function(j,f){ -var a=require("fs").open,o=i();function p(r,e,t,s){var n=arguments.length;if(n===2)return a(r,o.flags,o.mode,e);if(n===3)return a(r,e,o.mode,t);a(r,e,t,s)}f.exports=p -});var m=u(function(k,l){ -var c=require("fs").openSync,v=i();function x(r,e,t){var s,n;s=arguments.length;try{s===1?n=c(r,v.flags,v.mode):s===2?n=c(r,e,v.mode):n=c(r,e,t)}catch(g){return g}return n}l.exports=x -});var S=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),q=d(),O=m();S(q,"sync",O);module.exports=q; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 65b6278..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/main.js", "../lib/sync.js", "../lib/index.js"], - "sourcesContent": ["{\n\t\"flags\": \"r\",\n\t\"mode\": 438\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var open = require( '@stdlib/fs-open' );\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nmodule.exports = open;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nmodule.exports = openSync;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var open = require( '@stdlib/fs-open' );\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var openSync = require( '@stdlib/fs-open' ).sync;\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar sync = require( './sync.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,CAAAA,EAAA,SACC,MAAS,IACT,KAAQ,GACT,ICHA,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAK,QAAS,IAAK,EAAE,KACrBC,EAAW,IA0Bf,SAASC,EAAMC,EAAMC,EAAOC,EAAMC,EAAO,CACxC,IAAIC,EAAQ,UAAU,OACtB,GAAKA,IAAU,EACd,OAAOP,EAAIG,EAAMF,EAAS,MAAOA,EAAS,KAAMG,CAAM,EAEvD,GAAKG,IAAU,EACd,OAAOP,EAAIG,EAAMC,EAAOH,EAAS,KAAMI,CAAK,EAE7CL,EAAIG,EAAMC,EAAOC,EAAMC,CAAK,CAC7B,CAKAP,EAAO,QAAUG,IC/DjB,IAAAM,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAO,QAAS,IAAK,EAAE,SACvBC,EAAW,IAsBf,SAASC,EAAUC,EAAMC,EAAOC,EAAO,CACtC,IAAIC,EACAC,EAEJD,EAAQ,UAAU,OAClB,GAAI,CACEA,IAAU,EACdC,EAAKP,EAAMG,EAAMF,EAAS,MAAOA,EAAS,IAAK,EACpCK,IAAU,EACrBC,EAAKP,EAAMG,EAAMC,EAAOH,EAAS,IAAK,EAEtCM,EAAKP,EAAMG,EAAMC,EAAOC,CAAK,CAE/B,OAAUG,EAAM,CACf,OAAOA,CACR,CACA,OAAOD,CACR,CAKAR,EAAO,QAAUG,ICjBjB,IAAIO,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAO,IAKXF,EAAaC,EAAM,OAAQC,CAAK,EAKhC,OAAO,QAAUD", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_main", "__commonJSMin", "exports", "module", "op", "defaults", "open", "path", "flags", "mode", "clbk", "nargs", "require_sync", "__commonJSMin", "exports", "module", "open", "defaults", "openSync", "path", "flags", "mode", "nargs", "fd", "err", "setReadOnly", "main", "sync"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4cbf7ac..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,65 +0,0 @@ - -{{alias}}( path[, flags[, mode]], clbk ) - Asynchronously opens a file. - - Some characters, such as <>:"/\|?*, are reserved under Windows. - Under NTFS, if the path contains a colon, Node.js will open a file system - stream. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - clbk: Function - Callback to invoke upon opening a file. - - Examples - -------- - > function onOpen( error, fd ) { - ... if ( error ) { - ... console.error( error.message ); - ... } else { - ... {{alias:@stdlib/fs/close}}.sync( fd ); - ... } - ... }; - > {{alias}}( './beep/boop.txt', onOpen ); - - -{{alias}}.sync( path[, flags[, mode]] ) - Synchronously opens a file. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - Returns - ------- - fd: Error|integer - File descriptor. - - Examples - -------- - > var fd = {{alias}}.sync( './beep/boop.txt' ); - > if ( !{{alias:@stdlib/assert/is-error}}( fd ) ) { {{alias:@stdlib/fs/close}}.sync( fd ); }; - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 67907a2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,129 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 open = require( './index' ); - -const done = ( error: Error, fd: number ) => { - if ( error || !fd ) { - throw error; - } -}; - - -// TESTS // - -// The function does not have a return value... -{ - open( '/path/to/beepboop', done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a string... -{ - open( 123, done ); // $ExpectError - open( false, done ); // $ExpectError - open( true, done ); // $ExpectError - open( null, done ); // $ExpectError - open( undefined, done ); // $ExpectError - open( [], done ); // $ExpectError - open( {}, done ); // $ExpectError - open( ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a last argument which is not a function with the expected signature... -{ - open( '/path/to/beepboop', 'abc' ); // $ExpectError - open( '/path/to/beepboop', 123 ); // $ExpectError - open( '/path/to/beepboop', false ); // $ExpectError - open( '/path/to/beepboop', true ); // $ExpectError - open( '/path/to/beepboop', null ); // $ExpectError - open( '/path/to/beepboop', undefined ); // $ExpectError - open( '/path/to/beepboop', [] ); // $ExpectError - open( '/path/to/beepboop', {} ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `flags` argument which is not a string or number... -{ - open( '/path/to/beepboop', false, done ); // $ExpectError - open( '/path/to/beepboop', true, done ); // $ExpectError - open( '/path/to/beepboop', null, done ); // $ExpectError - open( '/path/to/beepboop', undefined, done ); // $ExpectError - open( '/path/to/beepboop', [], done ); // $ExpectError - open( '/path/to/beepboop', {}, done ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` argument which is not a number... -{ - open( '/path/to/beepboop', 'r+', 'abc', done ); // $ExpectError - open( '/path/to/beepboop', 'r+', false, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', true, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', null, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', undefined, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', [], done ); // $ExpectError - open( '/path/to/beepboop', 'r+', {}, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - open(); // $ExpectError - open( 'C:\\foo\\bar\\baz' ); // $ExpectError -} - -// Attached to main export is a `sync` method which returns a number or an error... -{ - open.sync( '/path/to/beepboop' ); // $ExpectType number | Error -} - -// The compiler throws an error if the `sync` method is provided a first argument which is not a string... -{ - open.sync( 123 ); // $ExpectError - open.sync( false ); // $ExpectError - open.sync( true ); // $ExpectError - open.sync( null ); // $ExpectError - open.sync( undefined ); // $ExpectError - open.sync( [] ); // $ExpectError - open.sync( {} ); // $ExpectError - open.sync( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a second argument which is not a string or number... -{ - open.sync( '/path/to/beepboop', false ); // $ExpectError - open.sync( '/path/to/beepboop', true ); // $ExpectError - open.sync( '/path/to/beepboop', null ); // $ExpectError - open.sync( '/path/to/beepboop', [] ); // $ExpectError - open.sync( '/path/to/beepboop', {} ); // $ExpectError - open.sync( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a third argument which is not a number... -{ - open.sync( '/path/to/beepboop', 'r+', false ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', true ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', null ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', [] ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', {} ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided an unsupported number of arguments... -{ - open.sync(); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 71359fe..0000000 --- a/examples/index.js +++ /dev/null @@ -1,56 +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. -*/ - -'use strict'; - -var closeSync = require( '@stdlib/fs-close' ).sync; -var isError = require( '@stdlib/assert-is-error' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - -/* Sync */ - -var fd = open.sync( __filename, 'r+' ); -// returns - -console.log( isError( fd ) ); -// => false - -closeSync( fd ); - -fd = open.sync( 'beepboop' ); -// returns - -console.log( isError( fd ) ); -// => true - -/* Async */ - -open( __filename, onOpen ); -open( 'beepboop', onOpen ); - -function onOpen( error, fd ) { - if ( error ) { - if ( error.code === 'ENOENT' ) { - console.error( 'File does not exist.' ); - } else { - throw error; - } - } else { - closeSync( fd ); - } -} 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..9e3afbc --- /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/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var r=t(Object.freeze({__proto__:null,default:{}})),n="r",o=438,c=r.open;function u(e,t,r,u){var i=arguments.length;return 2===i?c(e,n,o,t):3===i?c(e,t,o,r):void c(e,t,r,u)}var i=r.openSync;function s(e,t,r){var c,u;c=arguments.length;try{u=1===c?i(e,n,o):i(e,t,2===c?o:r)}catch(e){return e}return u}e(u,"sync",s);export{u as default,s as sync}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..0d9f33f --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;0nBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAEzB,CAAC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index cb174b7..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "flags": "r", - "mode": 438 -} diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 8edd6de..0000000 --- a/lib/index.js +++ /dev/null @@ -1,63 +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. -*/ - -'use strict'; - -/** -* Open a file. -* -* @module @stdlib/fs-open -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var openSync = require( '@stdlib/fs-open' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var sync = require( './sync.js' ); - - -// MAIN // - -setReadOnly( main, 'sync', sync ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index feb5171..0000000 --- a/lib/main.js +++ /dev/null @@ -1,64 +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. -*/ - -'use strict'; - -// MODULES // - -var op = require( 'fs' ).open; -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Asynchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @param {Function} clbk - callback to invoke after opening a file -* @returns {void} -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -*/ -function open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare - var nargs = arguments.length; - if ( nargs === 2 ) { - return op( path, defaults.flags, defaults.mode, flags ); - } - if ( nargs === 3 ) { - return op( path, flags, defaults.mode, mode ); - } - op( path, flags, mode, clbk ); -} - - -// EXPORTS // - -module.exports = open; diff --git a/lib/sync.js b/lib/sync.js deleted file mode 100644 index d8d2e00..0000000 --- a/lib/sync.js +++ /dev/null @@ -1,68 +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. -*/ - -'use strict'; - -// MODULES // - -var open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Synchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @returns {(integer|Error)} file descriptor or an error -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -function openSync( path, flags, mode ) { - var nargs; - var fd; - - nargs = arguments.length; - try { - if ( nargs === 1 ) { - fd = open( path, defaults.flags, defaults.mode ); - } else if ( nargs === 2 ) { - fd = open( path, flags, defaults.mode ); - } else { - fd = open( path, flags, mode ); - } - } catch ( err ) { - return err; - } - return fd; -} - - -// EXPORTS // - -module.exports = openSync; diff --git a/package.json b/package.json index b373e1d..b313f37 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Open a file.", "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/utils-define-nonenumerable-read-only-property": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.2.1", - "@stdlib/assert-is-error": "^0.2.1", - "@stdlib/assert-is-nonnegative-integer": "^0.2.1", - "@stdlib/fs-close": "^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", "stdfs", @@ -82,4 +30,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..34bd866 --- /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 3c47135..0000000 --- a/test/test.js +++ /dev/null @@ -1,38 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is a function to open a file synchronously', function test( t ) { - t.equal( typeof open.sync, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 33b938f..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,110 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/main.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - open( __filename, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - open( __filename, 'r+', onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - open( __filename, 'r+', 438, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - open( 'beepboopbapbop', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', 438, onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); diff --git a/test/test.sync.js b/test/test.sync.js deleted file mode 100644 index 56d7b23..0000000 --- a/test/test.sync.js +++ /dev/null @@ -1,83 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/sync.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - var fd = open( __filename ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - var fd = open( __filename, 'r+' ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - var fd = open( __filename, 'r+', 438 ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - var fd = open( 'beepboopbapbop' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+', 438 ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); From 7d72af78906cf79d400ff34662c15e95bca2bede Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jun 2024 00:53:52 +0000 Subject: [PATCH 085/113] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 8dbf5e0..b373e1d 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.2.1", @@ -81,4 +82,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From a10c20d764bf26907f2c5db1bb9e86eac0a86725 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jun 2024 01:19:46 +0000 Subject: [PATCH 086/113] Remove files --- index.d.ts | 150 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4997 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 dddbd0c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,150 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Buffer } from 'buffer'; - -/** -* Callback invoked after opening a file. -* -* @param err - error argument -* @param fd - file descriptor -*/ -type Callback = ( err: Error, fd: number ) => void; - -/** -* Interface for opening a file. -*/ -interface Open { - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', 438, onOpen ); - */ - ( path: string | Buffer, flags: string | number, mode: number, clbk: Callback ): void; - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', onOpen ); - */ - ( path: string | Buffer, flags: string | number, clbk: Callback ): void; - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, onOpen ); - */ - ( path: string | Buffer, clbk: Callback ): void; - - /** - * Synchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @returns file descriptor or an error - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * var fd = open.sync( __filename, 'r+' ); - * if ( fd instanceof Error ) { - * throw fd; - * } - * closeSync( fd ); - */ - sync( path: string | Buffer, flags?: string | number, mode?: number ): number | Error; -} - -/** -* Asynchronously opens a file. -* -* @param path - file path -* @param flags - file system flags (default: 'r') -* @param mode - file mode (default: 0o666) -* @param clbk - callback to invoke after opening a file -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* var fd = open.sync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -declare var open: Open; - - -// EXPORTS // - -export = open; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 9e3afbc..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/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var r=t(Object.freeze({__proto__:null,default:{}})),n="r",o=438,c=r.open;function u(e,t,r,u){var i=arguments.length;return 2===i?c(e,n,o,t):3===i?c(e,t,o,r):void c(e,t,r,u)}var i=r.openSync;function s(e,t,r){var c,u;c=arguments.length;try{u=1===c?i(e,n,o):i(e,t,2===c?o:r)}catch(e){return e}return u}e(u,"sync",s);export{u as default,s as sync}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 0d9f33f..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;0nBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAEzB,CAAC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 34bd866..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 30a65d50667376a75363ae5739de91865c930ba7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 1 Jun 2024 01:20:03 +0000 Subject: [PATCH 087/113] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 248 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 55 +- SECURITY.md | 5 - benchmark/benchmark.js | 77 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 65 - docs/types/test.ts | 129 - examples/index.js | 56 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/defaults.json | 4 - lib/index.js | 63 - lib/main.js | 64 - lib/sync.js | 68 - package.json | 58 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 38 - test/test.main.js | 110 - test/test.sync.js | 83 - 47 files changed, 4876 insertions(+), 4127 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/defaults.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/sync.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.sync.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 031993d..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-06-01T00:46:29.936Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index a3a4470..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/fs/open) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 7617ad3..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/fs/open) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 d7fc8a0..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: '14 2 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f92a6c5..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -225,7 +222,7 @@ function onOpen( error, fd ) { ## 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]. @@ -292,11 +289,11 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close +[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close/tree/esm -[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists +[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists/tree/esm -[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file +[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file/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 503cc81..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,77 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var closeSync = require( '@stdlib/fs-close' ).sync; -var pkg = require( './../package.json' ).name; -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return open( __filename, 'r+', done ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function done( error, fd ) { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - if ( error ) { - b.fail( error.message ); - } - next(); - } -}); - -bench( pkg+':sync', function benchmark( b ) { - var fd; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - fd = open.sync( __filename, 'r+' ); - if ( fd instanceof Error ) { - b.fail( fd.message ); - } else { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - } - } - b.toc(); - if ( fd instanceof Error ) { - b.fail( 'something went wrong' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index da1ba5f..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/fs/open" -%% click B href "https://github.com/stdlib-js/fs-open/tree/main" -%% click C href "https://github.com/stdlib-js/fs-open/tree/production" -%% click D href "https://github.com/stdlib-js/fs-open/tree/esm" -%% click E href "https://github.com/stdlib-js/fs-open/tree/deno" -%% click F href "https://github.com/stdlib-js/fs-open/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/fs/open -[production-url]: https://github.com/stdlib-js/fs-open/tree/production -[deno-url]: https://github.com/stdlib-js/fs-open/tree/deno -[deno-readme]: https://github.com/stdlib-js/fs-open/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/fs-open/tree/umd -[umd-readme]: https://github.com/stdlib-js/fs-open/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/fs-open/tree/esm -[esm-readme]: https://github.com/stdlib-js/fs-open/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 3e10601..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import open from '../docs/types/index'; -export = open; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 5358415..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var u=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var i=u(function(b,y){y.exports={flags:"r",mode:438}});var d=u(function(j,f){ -var a=require("fs").open,o=i();function p(r,e,t,s){var n=arguments.length;if(n===2)return a(r,o.flags,o.mode,e);if(n===3)return a(r,e,o.mode,t);a(r,e,t,s)}f.exports=p -});var m=u(function(k,l){ -var c=require("fs").openSync,v=i();function x(r,e,t){var s,n;s=arguments.length;try{s===1?n=c(r,v.flags,v.mode):s===2?n=c(r,e,v.mode):n=c(r,e,t)}catch(g){return g}return n}l.exports=x -});var S=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),q=d(),O=m();S(q,"sync",O);module.exports=q; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 65b6278..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/main.js", "../lib/sync.js", "../lib/index.js"], - "sourcesContent": ["{\n\t\"flags\": \"r\",\n\t\"mode\": 438\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var open = require( '@stdlib/fs-open' );\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nmodule.exports = open;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nmodule.exports = openSync;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var open = require( '@stdlib/fs-open' );\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var openSync = require( '@stdlib/fs-open' ).sync;\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar sync = require( './sync.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,CAAAA,EAAA,SACC,MAAS,IACT,KAAQ,GACT,ICHA,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAK,QAAS,IAAK,EAAE,KACrBC,EAAW,IA0Bf,SAASC,EAAMC,EAAMC,EAAOC,EAAMC,EAAO,CACxC,IAAIC,EAAQ,UAAU,OACtB,GAAKA,IAAU,EACd,OAAOP,EAAIG,EAAMF,EAAS,MAAOA,EAAS,KAAMG,CAAM,EAEvD,GAAKG,IAAU,EACd,OAAOP,EAAIG,EAAMC,EAAOH,EAAS,KAAMI,CAAK,EAE7CL,EAAIG,EAAMC,EAAOC,EAAMC,CAAK,CAC7B,CAKAP,EAAO,QAAUG,IC/DjB,IAAAM,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAO,QAAS,IAAK,EAAE,SACvBC,EAAW,IAsBf,SAASC,EAAUC,EAAMC,EAAOC,EAAO,CACtC,IAAIC,EACAC,EAEJD,EAAQ,UAAU,OAClB,GAAI,CACEA,IAAU,EACdC,EAAKP,EAAMG,EAAMF,EAAS,MAAOA,EAAS,IAAK,EACpCK,IAAU,EACrBC,EAAKP,EAAMG,EAAMC,EAAOH,EAAS,IAAK,EAEtCM,EAAKP,EAAMG,EAAMC,EAAOC,CAAK,CAE/B,OAAUG,EAAM,CACf,OAAOA,CACR,CACA,OAAOD,CACR,CAKAR,EAAO,QAAUG,ICjBjB,IAAIO,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAO,IAKXF,EAAaC,EAAM,OAAQC,CAAK,EAKhC,OAAO,QAAUD", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_main", "__commonJSMin", "exports", "module", "op", "defaults", "open", "path", "flags", "mode", "clbk", "nargs", "require_sync", "__commonJSMin", "exports", "module", "open", "defaults", "openSync", "path", "flags", "mode", "nargs", "fd", "err", "setReadOnly", "main", "sync"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4cbf7ac..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,65 +0,0 @@ - -{{alias}}( path[, flags[, mode]], clbk ) - Asynchronously opens a file. - - Some characters, such as <>:"/\|?*, are reserved under Windows. - Under NTFS, if the path contains a colon, Node.js will open a file system - stream. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - clbk: Function - Callback to invoke upon opening a file. - - Examples - -------- - > function onOpen( error, fd ) { - ... if ( error ) { - ... console.error( error.message ); - ... } else { - ... {{alias:@stdlib/fs/close}}.sync( fd ); - ... } - ... }; - > {{alias}}( './beep/boop.txt', onOpen ); - - -{{alias}}.sync( path[, flags[, mode]] ) - Synchronously opens a file. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - Returns - ------- - fd: Error|integer - File descriptor. - - Examples - -------- - > var fd = {{alias}}.sync( './beep/boop.txt' ); - > if ( !{{alias:@stdlib/assert/is-error}}( fd ) ) { {{alias:@stdlib/fs/close}}.sync( fd ); }; - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 67907a2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,129 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 open = require( './index' ); - -const done = ( error: Error, fd: number ) => { - if ( error || !fd ) { - throw error; - } -}; - - -// TESTS // - -// The function does not have a return value... -{ - open( '/path/to/beepboop', done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a string... -{ - open( 123, done ); // $ExpectError - open( false, done ); // $ExpectError - open( true, done ); // $ExpectError - open( null, done ); // $ExpectError - open( undefined, done ); // $ExpectError - open( [], done ); // $ExpectError - open( {}, done ); // $ExpectError - open( ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a last argument which is not a function with the expected signature... -{ - open( '/path/to/beepboop', 'abc' ); // $ExpectError - open( '/path/to/beepboop', 123 ); // $ExpectError - open( '/path/to/beepboop', false ); // $ExpectError - open( '/path/to/beepboop', true ); // $ExpectError - open( '/path/to/beepboop', null ); // $ExpectError - open( '/path/to/beepboop', undefined ); // $ExpectError - open( '/path/to/beepboop', [] ); // $ExpectError - open( '/path/to/beepboop', {} ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `flags` argument which is not a string or number... -{ - open( '/path/to/beepboop', false, done ); // $ExpectError - open( '/path/to/beepboop', true, done ); // $ExpectError - open( '/path/to/beepboop', null, done ); // $ExpectError - open( '/path/to/beepboop', undefined, done ); // $ExpectError - open( '/path/to/beepboop', [], done ); // $ExpectError - open( '/path/to/beepboop', {}, done ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` argument which is not a number... -{ - open( '/path/to/beepboop', 'r+', 'abc', done ); // $ExpectError - open( '/path/to/beepboop', 'r+', false, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', true, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', null, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', undefined, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', [], done ); // $ExpectError - open( '/path/to/beepboop', 'r+', {}, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - open(); // $ExpectError - open( 'C:\\foo\\bar\\baz' ); // $ExpectError -} - -// Attached to main export is a `sync` method which returns a number or an error... -{ - open.sync( '/path/to/beepboop' ); // $ExpectType number | Error -} - -// The compiler throws an error if the `sync` method is provided a first argument which is not a string... -{ - open.sync( 123 ); // $ExpectError - open.sync( false ); // $ExpectError - open.sync( true ); // $ExpectError - open.sync( null ); // $ExpectError - open.sync( undefined ); // $ExpectError - open.sync( [] ); // $ExpectError - open.sync( {} ); // $ExpectError - open.sync( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a second argument which is not a string or number... -{ - open.sync( '/path/to/beepboop', false ); // $ExpectError - open.sync( '/path/to/beepboop', true ); // $ExpectError - open.sync( '/path/to/beepboop', null ); // $ExpectError - open.sync( '/path/to/beepboop', [] ); // $ExpectError - open.sync( '/path/to/beepboop', {} ); // $ExpectError - open.sync( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a third argument which is not a number... -{ - open.sync( '/path/to/beepboop', 'r+', false ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', true ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', null ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', [] ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', {} ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided an unsupported number of arguments... -{ - open.sync(); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 71359fe..0000000 --- a/examples/index.js +++ /dev/null @@ -1,56 +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. -*/ - -'use strict'; - -var closeSync = require( '@stdlib/fs-close' ).sync; -var isError = require( '@stdlib/assert-is-error' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - -/* Sync */ - -var fd = open.sync( __filename, 'r+' ); -// returns - -console.log( isError( fd ) ); -// => false - -closeSync( fd ); - -fd = open.sync( 'beepboop' ); -// returns - -console.log( isError( fd ) ); -// => true - -/* Async */ - -open( __filename, onOpen ); -open( 'beepboop', onOpen ); - -function onOpen( error, fd ) { - if ( error ) { - if ( error.code === 'ENOENT' ) { - console.error( 'File does not exist.' ); - } else { - throw error; - } - } else { - closeSync( fd ); - } -} 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..9e3afbc --- /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/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var r=t(Object.freeze({__proto__:null,default:{}})),n="r",o=438,c=r.open;function u(e,t,r,u){var i=arguments.length;return 2===i?c(e,n,o,t):3===i?c(e,t,o,r):void c(e,t,r,u)}var i=r.openSync;function s(e,t,r){var c,u;c=arguments.length;try{u=1===c?i(e,n,o):i(e,t,2===c?o:r)}catch(e){return e}return u}e(u,"sync",s);export{u as default,s as sync}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..0d9f33f --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;0nBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAEzB,CAAC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index cb174b7..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "flags": "r", - "mode": 438 -} diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 8edd6de..0000000 --- a/lib/index.js +++ /dev/null @@ -1,63 +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. -*/ - -'use strict'; - -/** -* Open a file. -* -* @module @stdlib/fs-open -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var openSync = require( '@stdlib/fs-open' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var sync = require( './sync.js' ); - - -// MAIN // - -setReadOnly( main, 'sync', sync ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index feb5171..0000000 --- a/lib/main.js +++ /dev/null @@ -1,64 +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. -*/ - -'use strict'; - -// MODULES // - -var op = require( 'fs' ).open; -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Asynchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @param {Function} clbk - callback to invoke after opening a file -* @returns {void} -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -*/ -function open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare - var nargs = arguments.length; - if ( nargs === 2 ) { - return op( path, defaults.flags, defaults.mode, flags ); - } - if ( nargs === 3 ) { - return op( path, flags, defaults.mode, mode ); - } - op( path, flags, mode, clbk ); -} - - -// EXPORTS // - -module.exports = open; diff --git a/lib/sync.js b/lib/sync.js deleted file mode 100644 index d8d2e00..0000000 --- a/lib/sync.js +++ /dev/null @@ -1,68 +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. -*/ - -'use strict'; - -// MODULES // - -var open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Synchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @returns {(integer|Error)} file descriptor or an error -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -function openSync( path, flags, mode ) { - var nargs; - var fd; - - nargs = arguments.length; - try { - if ( nargs === 1 ) { - fd = open( path, defaults.flags, defaults.mode ); - } else if ( nargs === 2 ) { - fd = open( path, flags, defaults.mode ); - } else { - fd = open( path, flags, mode ); - } - } catch ( err ) { - return err; - } - return fd; -} - - -// EXPORTS // - -module.exports = openSync; diff --git a/package.json b/package.json index b373e1d..b313f37 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Open a file.", "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/utils-define-nonenumerable-read-only-property": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.2.1", - "@stdlib/assert-is-error": "^0.2.1", - "@stdlib/assert-is-nonnegative-integer": "^0.2.1", - "@stdlib/fs-close": "^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", "stdfs", @@ -82,4 +30,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..34bd866 --- /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 3c47135..0000000 --- a/test/test.js +++ /dev/null @@ -1,38 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is a function to open a file synchronously', function test( t ) { - t.equal( typeof open.sync, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 33b938f..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,110 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/main.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - open( __filename, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - open( __filename, 'r+', onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - open( __filename, 'r+', 438, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - open( 'beepboopbapbop', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', 438, onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); diff --git a/test/test.sync.js b/test/test.sync.js deleted file mode 100644 index 56d7b23..0000000 --- a/test/test.sync.js +++ /dev/null @@ -1,83 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/sync.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - var fd = open( __filename ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - var fd = open( __filename, 'r+' ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - var fd = open( __filename, 'r+', 438 ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - var fd = open( 'beepboopbapbop' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+', 438 ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); From 3e5ceac9a1ccc615be5feecdcbd42c064ece190b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jul 2024 00:55:26 +0000 Subject: [PATCH 088/113] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 8dbf5e0..b373e1d 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.2.1", @@ -81,4 +82,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 55d8c62d1d5175e0048e20ad0c130024cd2d05fe Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jul 2024 01:31:25 +0000 Subject: [PATCH 089/113] Remove files --- index.d.ts | 150 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4997 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 dddbd0c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,150 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Buffer } from 'buffer'; - -/** -* Callback invoked after opening a file. -* -* @param err - error argument -* @param fd - file descriptor -*/ -type Callback = ( err: Error, fd: number ) => void; - -/** -* Interface for opening a file. -*/ -interface Open { - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', 438, onOpen ); - */ - ( path: string | Buffer, flags: string | number, mode: number, clbk: Callback ): void; - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', onOpen ); - */ - ( path: string | Buffer, flags: string | number, clbk: Callback ): void; - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, onOpen ); - */ - ( path: string | Buffer, clbk: Callback ): void; - - /** - * Synchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @returns file descriptor or an error - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * var fd = open.sync( __filename, 'r+' ); - * if ( fd instanceof Error ) { - * throw fd; - * } - * closeSync( fd ); - */ - sync( path: string | Buffer, flags?: string | number, mode?: number ): number | Error; -} - -/** -* Asynchronously opens a file. -* -* @param path - file path -* @param flags - file system flags (default: 'r') -* @param mode - file mode (default: 0o666) -* @param clbk - callback to invoke after opening a file -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* var fd = open.sync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -declare var open: Open; - - -// EXPORTS // - -export = open; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 9e3afbc..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/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var r=t(Object.freeze({__proto__:null,default:{}})),n="r",o=438,c=r.open;function u(e,t,r,u){var i=arguments.length;return 2===i?c(e,n,o,t):3===i?c(e,t,o,r):void c(e,t,r,u)}var i=r.openSync;function s(e,t,r){var c,u;c=arguments.length;try{u=1===c?i(e,n,o):i(e,t,2===c?o:r)}catch(e){return e}return u}e(u,"sync",s);export{u as default,s as sync}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 0d9f33f..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;0nBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAEzB,CAAC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 34bd866..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From ed2a64240ba84031c4c6c38298756eb6026feff8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jul 2024 01:31:41 +0000 Subject: [PATCH 090/113] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 38 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 55 +- SECURITY.md | 5 - benchmark/benchmark.js | 77 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 65 - docs/types/test.ts | 129 - examples/index.js | 56 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/defaults.json | 4 - lib/index.js | 63 - lib/main.js | 64 - lib/sync.js | 68 - package.json | 58 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 38 - test/test.main.js | 110 - test/test.sync.js | 83 - 47 files changed, 4876 insertions(+), 4164 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/defaults.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/sync.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.sync.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 419ca4f..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-07-01T00:48:31.544Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index a3a4470..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/fs/open) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 7617ad3..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/fs/open) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 d7fc8a0..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: '14 2 * * 3' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index f92a6c5..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,794 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -225,7 +222,7 @@ function onOpen( error, fd ) { ## 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]. @@ -292,11 +289,11 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close +[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close/tree/esm -[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists +[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists/tree/esm -[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file +[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file/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 503cc81..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,77 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var closeSync = require( '@stdlib/fs-close' ).sync; -var pkg = require( './../package.json' ).name; -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return open( __filename, 'r+', done ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function done( error, fd ) { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - if ( error ) { - b.fail( error.message ); - } - next(); - } -}); - -bench( pkg+':sync', function benchmark( b ) { - var fd; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - fd = open.sync( __filename, 'r+' ); - if ( fd instanceof Error ) { - b.fail( fd.message ); - } else { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - } - } - b.toc(); - if ( fd instanceof Error ) { - b.fail( 'something went wrong' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index da1ba5f..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/fs/open" -%% click B href "https://github.com/stdlib-js/fs-open/tree/main" -%% click C href "https://github.com/stdlib-js/fs-open/tree/production" -%% click D href "https://github.com/stdlib-js/fs-open/tree/esm" -%% click E href "https://github.com/stdlib-js/fs-open/tree/deno" -%% click F href "https://github.com/stdlib-js/fs-open/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/fs/open -[production-url]: https://github.com/stdlib-js/fs-open/tree/production -[deno-url]: https://github.com/stdlib-js/fs-open/tree/deno -[deno-readme]: https://github.com/stdlib-js/fs-open/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/fs-open/tree/umd -[umd-readme]: https://github.com/stdlib-js/fs-open/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/fs-open/tree/esm -[esm-readme]: https://github.com/stdlib-js/fs-open/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 3e10601..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import open from '../docs/types/index'; -export = open; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 5358415..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var u=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var i=u(function(b,y){y.exports={flags:"r",mode:438}});var d=u(function(j,f){ -var a=require("fs").open,o=i();function p(r,e,t,s){var n=arguments.length;if(n===2)return a(r,o.flags,o.mode,e);if(n===3)return a(r,e,o.mode,t);a(r,e,t,s)}f.exports=p -});var m=u(function(k,l){ -var c=require("fs").openSync,v=i();function x(r,e,t){var s,n;s=arguments.length;try{s===1?n=c(r,v.flags,v.mode):s===2?n=c(r,e,v.mode):n=c(r,e,t)}catch(g){return g}return n}l.exports=x -});var S=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),q=d(),O=m();S(q,"sync",O);module.exports=q; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 65b6278..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/main.js", "../lib/sync.js", "../lib/index.js"], - "sourcesContent": ["{\n\t\"flags\": \"r\",\n\t\"mode\": 438\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var open = require( '@stdlib/fs-open' );\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nmodule.exports = open;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nmodule.exports = openSync;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var open = require( '@stdlib/fs-open' );\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var openSync = require( '@stdlib/fs-open' ).sync;\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar sync = require( './sync.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,CAAAA,EAAA,SACC,MAAS,IACT,KAAQ,GACT,ICHA,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAK,QAAS,IAAK,EAAE,KACrBC,EAAW,IA0Bf,SAASC,EAAMC,EAAMC,EAAOC,EAAMC,EAAO,CACxC,IAAIC,EAAQ,UAAU,OACtB,GAAKA,IAAU,EACd,OAAOP,EAAIG,EAAMF,EAAS,MAAOA,EAAS,KAAMG,CAAM,EAEvD,GAAKG,IAAU,EACd,OAAOP,EAAIG,EAAMC,EAAOH,EAAS,KAAMI,CAAK,EAE7CL,EAAIG,EAAMC,EAAOC,EAAMC,CAAK,CAC7B,CAKAP,EAAO,QAAUG,IC/DjB,IAAAM,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAO,QAAS,IAAK,EAAE,SACvBC,EAAW,IAsBf,SAASC,EAAUC,EAAMC,EAAOC,EAAO,CACtC,IAAIC,EACAC,EAEJD,EAAQ,UAAU,OAClB,GAAI,CACEA,IAAU,EACdC,EAAKP,EAAMG,EAAMF,EAAS,MAAOA,EAAS,IAAK,EACpCK,IAAU,EACrBC,EAAKP,EAAMG,EAAMC,EAAOH,EAAS,IAAK,EAEtCM,EAAKP,EAAMG,EAAMC,EAAOC,CAAK,CAE/B,OAAUG,EAAM,CACf,OAAOA,CACR,CACA,OAAOD,CACR,CAKAR,EAAO,QAAUG,ICjBjB,IAAIO,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAO,IAKXF,EAAaC,EAAM,OAAQC,CAAK,EAKhC,OAAO,QAAUD", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_main", "__commonJSMin", "exports", "module", "op", "defaults", "open", "path", "flags", "mode", "clbk", "nargs", "require_sync", "__commonJSMin", "exports", "module", "open", "defaults", "openSync", "path", "flags", "mode", "nargs", "fd", "err", "setReadOnly", "main", "sync"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4cbf7ac..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,65 +0,0 @@ - -{{alias}}( path[, flags[, mode]], clbk ) - Asynchronously opens a file. - - Some characters, such as <>:"/\|?*, are reserved under Windows. - Under NTFS, if the path contains a colon, Node.js will open a file system - stream. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - clbk: Function - Callback to invoke upon opening a file. - - Examples - -------- - > function onOpen( error, fd ) { - ... if ( error ) { - ... console.error( error.message ); - ... } else { - ... {{alias:@stdlib/fs/close}}.sync( fd ); - ... } - ... }; - > {{alias}}( './beep/boop.txt', onOpen ); - - -{{alias}}.sync( path[, flags[, mode]] ) - Synchronously opens a file. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - Returns - ------- - fd: Error|integer - File descriptor. - - Examples - -------- - > var fd = {{alias}}.sync( './beep/boop.txt' ); - > if ( !{{alias:@stdlib/assert/is-error}}( fd ) ) { {{alias:@stdlib/fs/close}}.sync( fd ); }; - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 67907a2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,129 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 open = require( './index' ); - -const done = ( error: Error, fd: number ) => { - if ( error || !fd ) { - throw error; - } -}; - - -// TESTS // - -// The function does not have a return value... -{ - open( '/path/to/beepboop', done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a string... -{ - open( 123, done ); // $ExpectError - open( false, done ); // $ExpectError - open( true, done ); // $ExpectError - open( null, done ); // $ExpectError - open( undefined, done ); // $ExpectError - open( [], done ); // $ExpectError - open( {}, done ); // $ExpectError - open( ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a last argument which is not a function with the expected signature... -{ - open( '/path/to/beepboop', 'abc' ); // $ExpectError - open( '/path/to/beepboop', 123 ); // $ExpectError - open( '/path/to/beepboop', false ); // $ExpectError - open( '/path/to/beepboop', true ); // $ExpectError - open( '/path/to/beepboop', null ); // $ExpectError - open( '/path/to/beepboop', undefined ); // $ExpectError - open( '/path/to/beepboop', [] ); // $ExpectError - open( '/path/to/beepboop', {} ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `flags` argument which is not a string or number... -{ - open( '/path/to/beepboop', false, done ); // $ExpectError - open( '/path/to/beepboop', true, done ); // $ExpectError - open( '/path/to/beepboop', null, done ); // $ExpectError - open( '/path/to/beepboop', undefined, done ); // $ExpectError - open( '/path/to/beepboop', [], done ); // $ExpectError - open( '/path/to/beepboop', {}, done ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` argument which is not a number... -{ - open( '/path/to/beepboop', 'r+', 'abc', done ); // $ExpectError - open( '/path/to/beepboop', 'r+', false, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', true, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', null, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', undefined, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', [], done ); // $ExpectError - open( '/path/to/beepboop', 'r+', {}, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - open(); // $ExpectError - open( 'C:\\foo\\bar\\baz' ); // $ExpectError -} - -// Attached to main export is a `sync` method which returns a number or an error... -{ - open.sync( '/path/to/beepboop' ); // $ExpectType number | Error -} - -// The compiler throws an error if the `sync` method is provided a first argument which is not a string... -{ - open.sync( 123 ); // $ExpectError - open.sync( false ); // $ExpectError - open.sync( true ); // $ExpectError - open.sync( null ); // $ExpectError - open.sync( undefined ); // $ExpectError - open.sync( [] ); // $ExpectError - open.sync( {} ); // $ExpectError - open.sync( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a second argument which is not a string or number... -{ - open.sync( '/path/to/beepboop', false ); // $ExpectError - open.sync( '/path/to/beepboop', true ); // $ExpectError - open.sync( '/path/to/beepboop', null ); // $ExpectError - open.sync( '/path/to/beepboop', [] ); // $ExpectError - open.sync( '/path/to/beepboop', {} ); // $ExpectError - open.sync( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a third argument which is not a number... -{ - open.sync( '/path/to/beepboop', 'r+', false ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', true ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', null ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', [] ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', {} ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided an unsupported number of arguments... -{ - open.sync(); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 71359fe..0000000 --- a/examples/index.js +++ /dev/null @@ -1,56 +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. -*/ - -'use strict'; - -var closeSync = require( '@stdlib/fs-close' ).sync; -var isError = require( '@stdlib/assert-is-error' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - -/* Sync */ - -var fd = open.sync( __filename, 'r+' ); -// returns - -console.log( isError( fd ) ); -// => false - -closeSync( fd ); - -fd = open.sync( 'beepboop' ); -// returns - -console.log( isError( fd ) ); -// => true - -/* Async */ - -open( __filename, onOpen ); -open( 'beepboop', onOpen ); - -function onOpen( error, fd ) { - if ( error ) { - if ( error.code === 'ENOENT' ) { - console.error( 'File does not exist.' ); - } else { - throw error; - } - } else { - closeSync( fd ); - } -} 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..9e3afbc --- /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/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var r=t(Object.freeze({__proto__:null,default:{}})),n="r",o=438,c=r.open;function u(e,t,r,u){var i=arguments.length;return 2===i?c(e,n,o,t):3===i?c(e,t,o,r):void c(e,t,r,u)}var i=r.openSync;function s(e,t,r){var c,u;c=arguments.length;try{u=1===c?i(e,n,o):i(e,t,2===c?o:r)}catch(e){return e}return u}e(u,"sync",s);export{u as default,s as sync}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..0d9f33f --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;0nBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAEzB,CAAC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index cb174b7..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "flags": "r", - "mode": 438 -} diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 8edd6de..0000000 --- a/lib/index.js +++ /dev/null @@ -1,63 +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. -*/ - -'use strict'; - -/** -* Open a file. -* -* @module @stdlib/fs-open -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var openSync = require( '@stdlib/fs-open' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var sync = require( './sync.js' ); - - -// MAIN // - -setReadOnly( main, 'sync', sync ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index feb5171..0000000 --- a/lib/main.js +++ /dev/null @@ -1,64 +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. -*/ - -'use strict'; - -// MODULES // - -var op = require( 'fs' ).open; -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Asynchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @param {Function} clbk - callback to invoke after opening a file -* @returns {void} -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -*/ -function open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare - var nargs = arguments.length; - if ( nargs === 2 ) { - return op( path, defaults.flags, defaults.mode, flags ); - } - if ( nargs === 3 ) { - return op( path, flags, defaults.mode, mode ); - } - op( path, flags, mode, clbk ); -} - - -// EXPORTS // - -module.exports = open; diff --git a/lib/sync.js b/lib/sync.js deleted file mode 100644 index d8d2e00..0000000 --- a/lib/sync.js +++ /dev/null @@ -1,68 +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. -*/ - -'use strict'; - -// MODULES // - -var open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Synchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @returns {(integer|Error)} file descriptor or an error -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -function openSync( path, flags, mode ) { - var nargs; - var fd; - - nargs = arguments.length; - try { - if ( nargs === 1 ) { - fd = open( path, defaults.flags, defaults.mode ); - } else if ( nargs === 2 ) { - fd = open( path, flags, defaults.mode ); - } else { - fd = open( path, flags, mode ); - } - } catch ( err ) { - return err; - } - return fd; -} - - -// EXPORTS // - -module.exports = openSync; diff --git a/package.json b/package.json index b373e1d..b313f37 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Open a file.", "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/utils-define-nonenumerable-read-only-property": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.2.1", - "@stdlib/assert-is-error": "^0.2.1", - "@stdlib/assert-is-nonnegative-integer": "^0.2.1", - "@stdlib/fs-close": "^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", "stdfs", @@ -82,4 +30,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..34bd866 --- /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 3c47135..0000000 --- a/test/test.js +++ /dev/null @@ -1,38 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is a function to open a file synchronously', function test( t ) { - t.equal( typeof open.sync, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 33b938f..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,110 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/main.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - open( __filename, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - open( __filename, 'r+', onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - open( __filename, 'r+', 438, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - open( 'beepboopbapbop', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', 438, onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); diff --git a/test/test.sync.js b/test/test.sync.js deleted file mode 100644 index 56d7b23..0000000 --- a/test/test.sync.js +++ /dev/null @@ -1,83 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/sync.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - var fd = open( __filename ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - var fd = open( __filename, 'r+' ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - var fd = open( __filename, 'r+', 438 ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - var fd = open( 'beepboopbapbop' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+', 438 ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); From ea73eec789b465889b456ac34bb648b32eb36604 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 26 Jul 2024 23:41:16 +0000 Subject: [PATCH 091/113] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index accbb79..127f594 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.2.1", @@ -81,4 +82,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 1181792c0651bf65ebc856c044fc35da4c09f310 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 26 Jul 2024 23:49:56 +0000 Subject: [PATCH 092/113] Remove files --- index.d.ts | 150 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4997 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 dddbd0c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,150 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Buffer } from 'buffer'; - -/** -* Callback invoked after opening a file. -* -* @param err - error argument -* @param fd - file descriptor -*/ -type Callback = ( err: Error, fd: number ) => void; - -/** -* Interface for opening a file. -*/ -interface Open { - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', 438, onOpen ); - */ - ( path: string | Buffer, flags: string | number, mode: number, clbk: Callback ): void; - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', onOpen ); - */ - ( path: string | Buffer, flags: string | number, clbk: Callback ): void; - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, onOpen ); - */ - ( path: string | Buffer, clbk: Callback ): void; - - /** - * Synchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @returns file descriptor or an error - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * var fd = open.sync( __filename, 'r+' ); - * if ( fd instanceof Error ) { - * throw fd; - * } - * closeSync( fd ); - */ - sync( path: string | Buffer, flags?: string | number, mode?: number ): number | Error; -} - -/** -* Asynchronously opens a file. -* -* @param path - file path -* @param flags - file system flags (default: 'r') -* @param mode - file mode (default: 0o666) -* @param clbk - callback to invoke after opening a file -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* var fd = open.sync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -declare var open: Open; - - -// EXPORTS // - -export = open; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 9e3afbc..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/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var r=t(Object.freeze({__proto__:null,default:{}})),n="r",o=438,c=r.open;function u(e,t,r,u){var i=arguments.length;return 2===i?c(e,n,o,t):3===i?c(e,t,o,r):void c(e,t,r,u)}var i=r.openSync;function s(e,t,r){var c,u;c=arguments.length;try{u=1===c?i(e,n,o):i(e,t,2===c?o:r)}catch(e){return e}return u}e(u,"sync",s);export{u as default,s as sync}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 0d9f33f..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;0nBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAEzB,CAAC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 34bd866..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From a7b6a489d986015ec24113fcac958c001f1ea58c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 26 Jul 2024 23:50:14 +0000 Subject: [PATCH 093/113] 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 | 197 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 55 +- SECURITY.md | 5 - benchmark/benchmark.js | 77 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 65 - docs/types/test.ts | 129 - examples/index.js | 56 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/defaults.json | 4 - lib/index.js | 63 - lib/main.js | 64 - lib/sync.js | 68 - package.json | 58 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 38 - test/test.main.js | 110 - test/test.sync.js | 83 - 46 files changed, 4876 insertions(+), 4322 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/defaults.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/sync.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.sync.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 a3a4470..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/fs/open) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 7617ad3..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/fs/open) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 d7fc8a0..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: '14 2 * * 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 + + ```
@@ -225,7 +222,7 @@ function onOpen( error, fd ) { ## 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]. @@ -292,11 +289,11 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close +[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close/tree/esm -[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists +[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists/tree/esm -[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file +[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file/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 503cc81..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,77 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var closeSync = require( '@stdlib/fs-close' ).sync; -var pkg = require( './../package.json' ).name; -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return open( __filename, 'r+', done ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function done( error, fd ) { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - if ( error ) { - b.fail( error.message ); - } - next(); - } -}); - -bench( pkg+':sync', function benchmark( b ) { - var fd; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - fd = open.sync( __filename, 'r+' ); - if ( fd instanceof Error ) { - b.fail( fd.message ); - } else { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - } - } - b.toc(); - if ( fd instanceof Error ) { - b.fail( 'something went wrong' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index da1ba5f..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/fs/open" -%% click B href "https://github.com/stdlib-js/fs-open/tree/main" -%% click C href "https://github.com/stdlib-js/fs-open/tree/production" -%% click D href "https://github.com/stdlib-js/fs-open/tree/esm" -%% click E href "https://github.com/stdlib-js/fs-open/tree/deno" -%% click F href "https://github.com/stdlib-js/fs-open/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/fs/open -[production-url]: https://github.com/stdlib-js/fs-open/tree/production -[deno-url]: https://github.com/stdlib-js/fs-open/tree/deno -[deno-readme]: https://github.com/stdlib-js/fs-open/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/fs-open/tree/umd -[umd-readme]: https://github.com/stdlib-js/fs-open/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/fs-open/tree/esm -[esm-readme]: https://github.com/stdlib-js/fs-open/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 3e10601..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import open from '../docs/types/index'; -export = open; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 5358415..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var u=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var i=u(function(b,y){y.exports={flags:"r",mode:438}});var d=u(function(j,f){ -var a=require("fs").open,o=i();function p(r,e,t,s){var n=arguments.length;if(n===2)return a(r,o.flags,o.mode,e);if(n===3)return a(r,e,o.mode,t);a(r,e,t,s)}f.exports=p -});var m=u(function(k,l){ -var c=require("fs").openSync,v=i();function x(r,e,t){var s,n;s=arguments.length;try{s===1?n=c(r,v.flags,v.mode):s===2?n=c(r,e,v.mode):n=c(r,e,t)}catch(g){return g}return n}l.exports=x -});var S=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),q=d(),O=m();S(q,"sync",O);module.exports=q; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 65b6278..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/main.js", "../lib/sync.js", "../lib/index.js"], - "sourcesContent": ["{\n\t\"flags\": \"r\",\n\t\"mode\": 438\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var open = require( '@stdlib/fs-open' );\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nmodule.exports = open;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nmodule.exports = openSync;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var open = require( '@stdlib/fs-open' );\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var openSync = require( '@stdlib/fs-open' ).sync;\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar sync = require( './sync.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,CAAAA,EAAA,SACC,MAAS,IACT,KAAQ,GACT,ICHA,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAK,QAAS,IAAK,EAAE,KACrBC,EAAW,IA0Bf,SAASC,EAAMC,EAAMC,EAAOC,EAAMC,EAAO,CACxC,IAAIC,EAAQ,UAAU,OACtB,GAAKA,IAAU,EACd,OAAOP,EAAIG,EAAMF,EAAS,MAAOA,EAAS,KAAMG,CAAM,EAEvD,GAAKG,IAAU,EACd,OAAOP,EAAIG,EAAMC,EAAOH,EAAS,KAAMI,CAAK,EAE7CL,EAAIG,EAAMC,EAAOC,EAAMC,CAAK,CAC7B,CAKAP,EAAO,QAAUG,IC/DjB,IAAAM,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAO,QAAS,IAAK,EAAE,SACvBC,EAAW,IAsBf,SAASC,EAAUC,EAAMC,EAAOC,EAAO,CACtC,IAAIC,EACAC,EAEJD,EAAQ,UAAU,OAClB,GAAI,CACEA,IAAU,EACdC,EAAKP,EAAMG,EAAMF,EAAS,MAAOA,EAAS,IAAK,EACpCK,IAAU,EACrBC,EAAKP,EAAMG,EAAMC,EAAOH,EAAS,IAAK,EAEtCM,EAAKP,EAAMG,EAAMC,EAAOC,CAAK,CAE/B,OAAUG,EAAM,CACf,OAAOA,CACR,CACA,OAAOD,CACR,CAKAR,EAAO,QAAUG,ICjBjB,IAAIO,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAO,IAKXF,EAAaC,EAAM,OAAQC,CAAK,EAKhC,OAAO,QAAUD", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_main", "__commonJSMin", "exports", "module", "op", "defaults", "open", "path", "flags", "mode", "clbk", "nargs", "require_sync", "__commonJSMin", "exports", "module", "open", "defaults", "openSync", "path", "flags", "mode", "nargs", "fd", "err", "setReadOnly", "main", "sync"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4cbf7ac..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,65 +0,0 @@ - -{{alias}}( path[, flags[, mode]], clbk ) - Asynchronously opens a file. - - Some characters, such as <>:"/\|?*, are reserved under Windows. - Under NTFS, if the path contains a colon, Node.js will open a file system - stream. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - clbk: Function - Callback to invoke upon opening a file. - - Examples - -------- - > function onOpen( error, fd ) { - ... if ( error ) { - ... console.error( error.message ); - ... } else { - ... {{alias:@stdlib/fs/close}}.sync( fd ); - ... } - ... }; - > {{alias}}( './beep/boop.txt', onOpen ); - - -{{alias}}.sync( path[, flags[, mode]] ) - Synchronously opens a file. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - Returns - ------- - fd: Error|integer - File descriptor. - - Examples - -------- - > var fd = {{alias}}.sync( './beep/boop.txt' ); - > if ( !{{alias:@stdlib/assert/is-error}}( fd ) ) { {{alias:@stdlib/fs/close}}.sync( fd ); }; - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 67907a2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,129 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 open = require( './index' ); - -const done = ( error: Error, fd: number ) => { - if ( error || !fd ) { - throw error; - } -}; - - -// TESTS // - -// The function does not have a return value... -{ - open( '/path/to/beepboop', done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a string... -{ - open( 123, done ); // $ExpectError - open( false, done ); // $ExpectError - open( true, done ); // $ExpectError - open( null, done ); // $ExpectError - open( undefined, done ); // $ExpectError - open( [], done ); // $ExpectError - open( {}, done ); // $ExpectError - open( ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a last argument which is not a function with the expected signature... -{ - open( '/path/to/beepboop', 'abc' ); // $ExpectError - open( '/path/to/beepboop', 123 ); // $ExpectError - open( '/path/to/beepboop', false ); // $ExpectError - open( '/path/to/beepboop', true ); // $ExpectError - open( '/path/to/beepboop', null ); // $ExpectError - open( '/path/to/beepboop', undefined ); // $ExpectError - open( '/path/to/beepboop', [] ); // $ExpectError - open( '/path/to/beepboop', {} ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `flags` argument which is not a string or number... -{ - open( '/path/to/beepboop', false, done ); // $ExpectError - open( '/path/to/beepboop', true, done ); // $ExpectError - open( '/path/to/beepboop', null, done ); // $ExpectError - open( '/path/to/beepboop', undefined, done ); // $ExpectError - open( '/path/to/beepboop', [], done ); // $ExpectError - open( '/path/to/beepboop', {}, done ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` argument which is not a number... -{ - open( '/path/to/beepboop', 'r+', 'abc', done ); // $ExpectError - open( '/path/to/beepboop', 'r+', false, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', true, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', null, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', undefined, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', [], done ); // $ExpectError - open( '/path/to/beepboop', 'r+', {}, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - open(); // $ExpectError - open( 'C:\\foo\\bar\\baz' ); // $ExpectError -} - -// Attached to main export is a `sync` method which returns a number or an error... -{ - open.sync( '/path/to/beepboop' ); // $ExpectType number | Error -} - -// The compiler throws an error if the `sync` method is provided a first argument which is not a string... -{ - open.sync( 123 ); // $ExpectError - open.sync( false ); // $ExpectError - open.sync( true ); // $ExpectError - open.sync( null ); // $ExpectError - open.sync( undefined ); // $ExpectError - open.sync( [] ); // $ExpectError - open.sync( {} ); // $ExpectError - open.sync( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a second argument which is not a string or number... -{ - open.sync( '/path/to/beepboop', false ); // $ExpectError - open.sync( '/path/to/beepboop', true ); // $ExpectError - open.sync( '/path/to/beepboop', null ); // $ExpectError - open.sync( '/path/to/beepboop', [] ); // $ExpectError - open.sync( '/path/to/beepboop', {} ); // $ExpectError - open.sync( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a third argument which is not a number... -{ - open.sync( '/path/to/beepboop', 'r+', false ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', true ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', null ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', [] ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', {} ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided an unsupported number of arguments... -{ - open.sync(); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 71359fe..0000000 --- a/examples/index.js +++ /dev/null @@ -1,56 +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. -*/ - -'use strict'; - -var closeSync = require( '@stdlib/fs-close' ).sync; -var isError = require( '@stdlib/assert-is-error' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - -/* Sync */ - -var fd = open.sync( __filename, 'r+' ); -// returns - -console.log( isError( fd ) ); -// => false - -closeSync( fd ); - -fd = open.sync( 'beepboop' ); -// returns - -console.log( isError( fd ) ); -// => true - -/* Async */ - -open( __filename, onOpen ); -open( 'beepboop', onOpen ); - -function onOpen( error, fd ) { - if ( error ) { - if ( error.code === 'ENOENT' ) { - console.error( 'File does not exist.' ); - } else { - throw error; - } - } else { - closeSync( fd ); - } -} 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..9e3afbc --- /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/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var r=t(Object.freeze({__proto__:null,default:{}})),n="r",o=438,c=r.open;function u(e,t,r,u){var i=arguments.length;return 2===i?c(e,n,o,t):3===i?c(e,t,o,r):void c(e,t,r,u)}var i=r.openSync;function s(e,t,r){var c,u;c=arguments.length;try{u=1===c?i(e,n,o):i(e,t,2===c?o:r)}catch(e){return e}return u}e(u,"sync",s);export{u as default,s as sync}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..0d9f33f --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;0nBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAEzB,CAAC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index cb174b7..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "flags": "r", - "mode": 438 -} diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 8edd6de..0000000 --- a/lib/index.js +++ /dev/null @@ -1,63 +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. -*/ - -'use strict'; - -/** -* Open a file. -* -* @module @stdlib/fs-open -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var openSync = require( '@stdlib/fs-open' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var sync = require( './sync.js' ); - - -// MAIN // - -setReadOnly( main, 'sync', sync ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index feb5171..0000000 --- a/lib/main.js +++ /dev/null @@ -1,64 +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. -*/ - -'use strict'; - -// MODULES // - -var op = require( 'fs' ).open; -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Asynchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @param {Function} clbk - callback to invoke after opening a file -* @returns {void} -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -*/ -function open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare - var nargs = arguments.length; - if ( nargs === 2 ) { - return op( path, defaults.flags, defaults.mode, flags ); - } - if ( nargs === 3 ) { - return op( path, flags, defaults.mode, mode ); - } - op( path, flags, mode, clbk ); -} - - -// EXPORTS // - -module.exports = open; diff --git a/lib/sync.js b/lib/sync.js deleted file mode 100644 index d8d2e00..0000000 --- a/lib/sync.js +++ /dev/null @@ -1,68 +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. -*/ - -'use strict'; - -// MODULES // - -var open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Synchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @returns {(integer|Error)} file descriptor or an error -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -function openSync( path, flags, mode ) { - var nargs; - var fd; - - nargs = arguments.length; - try { - if ( nargs === 1 ) { - fd = open( path, defaults.flags, defaults.mode ); - } else if ( nargs === 2 ) { - fd = open( path, flags, defaults.mode ); - } else { - fd = open( path, flags, mode ); - } - } catch ( err ) { - return err; - } - return fd; -} - - -// EXPORTS // - -module.exports = openSync; diff --git a/package.json b/package.json index 127f594..c2272c8 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Open a file.", "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/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.2.1", - "@stdlib/assert-is-error": "^0.2.1", - "@stdlib/assert-is-nonnegative-integer": "^0.2.1", - "@stdlib/fs-close": "^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", "stdfs", @@ -82,4 +30,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..34bd866 --- /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 3c47135..0000000 --- a/test/test.js +++ /dev/null @@ -1,38 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is a function to open a file synchronously', function test( t ) { - t.equal( typeof open.sync, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 33b938f..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,110 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/main.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - open( __filename, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - open( __filename, 'r+', onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - open( __filename, 'r+', 438, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - open( 'beepboopbapbop', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', 438, onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); diff --git a/test/test.sync.js b/test/test.sync.js deleted file mode 100644 index 56d7b23..0000000 --- a/test/test.sync.js +++ /dev/null @@ -1,83 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/sync.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - var fd = open( __filename ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - var fd = open( __filename, 'r+' ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - var fd = open( __filename, 'r+', 438 ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - var fd = open( 'beepboopbapbop' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+', 438 ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); From 51fa2b82382a4f5ce2c74cecc42ab7e272d30c85 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 26 Jul 2024 23:51:26 +0000 Subject: [PATCH 094/113] Update README.md for ESM bundle v0.2.2 --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index baa77f7..1cbd946 100644 --- a/README.md +++ b/README.md @@ -44,13 +44,13 @@ limitations under the License. ```javascript -import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@esm/index.mjs'; +import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@v0.2.2-esm/index.mjs'; ``` You can also import the following named exports from the package: ```javascript -import { sync } from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@esm/index.mjs'; +import { sync } from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@v0.2.2-esm/index.mjs'; ``` #### open( path\[, flags\[, mode]], clbk ) @@ -123,7 +123,7 @@ The function has the same default parameters as [`fs.openSync()`][node-fs]. ```javascript - import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@esm/index.mjs'; + import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@v0.2.2-esm/index.mjs'; var fpath = '/path/to/file.js'; @@ -155,7 +155,7 @@ The function has the same default parameters as [`fs.openSync()`][node-fs]. var join = require( 'path' ).join; var closeSync = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-close' ).sync; -import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@esm/index.mjs'; +import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@v0.2.2-esm/index.mjs'; /* Sync */ From 3d0793679de3344402f723686b8e95c66707d553 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 26 Jul 2024 23:51:27 +0000 Subject: [PATCH 095/113] Auto-generated commit --- README.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 1cbd946..609eaed 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,11 @@ limitations under the License. +```javascript +import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@esm/index.mjs'; +``` +The previous example will load the latest bundled code from the esm branch. Alternatively, you may load a specific version by loading the file from one of the [tagged bundles](https://github.com/stdlib-js/fs-open/tags). For example, + ```javascript import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@v0.2.2-esm/index.mjs'; ``` @@ -50,7 +55,7 @@ import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@v0.2.2-esm/index You can also import the following named exports from the package: ```javascript -import { sync } from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@v0.2.2-esm/index.mjs'; +import { sync } from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@esm/index.mjs'; ``` #### open( path\[, flags\[, mode]], clbk ) @@ -123,7 +128,7 @@ The function has the same default parameters as [`fs.openSync()`][node-fs]. ```javascript - import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@v0.2.2-esm/index.mjs'; + import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@esm/index.mjs'; var fpath = '/path/to/file.js'; @@ -155,7 +160,7 @@ The function has the same default parameters as [`fs.openSync()`][node-fs]. var join = require( 'path' ).join; var closeSync = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-close' ).sync; -import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@v0.2.2-esm/index.mjs'; +import open from 'https://cdn.jsdelivr.net/gh/stdlib-js/fs-open@esm/index.mjs'; /* Sync */ From a7846241328eeaf52045b98d22da6b03e0983e99 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 00:55:46 +0000 Subject: [PATCH 096/113] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index acacb8b..e20fa42 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.2.2", @@ -81,4 +82,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From e8c9f77381c7291021e30e9d7961cb15b0152daa Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 01:25:00 +0000 Subject: [PATCH 097/113] Remove files --- index.d.ts | 150 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4997 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 dddbd0c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,150 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Buffer } from 'buffer'; - -/** -* Callback invoked after opening a file. -* -* @param err - error argument -* @param fd - file descriptor -*/ -type Callback = ( err: Error, fd: number ) => void; - -/** -* Interface for opening a file. -*/ -interface Open { - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', 438, onOpen ); - */ - ( path: string | Buffer, flags: string | number, mode: number, clbk: Callback ): void; - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', onOpen ); - */ - ( path: string | Buffer, flags: string | number, clbk: Callback ): void; - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, onOpen ); - */ - ( path: string | Buffer, clbk: Callback ): void; - - /** - * Synchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @returns file descriptor or an error - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * var fd = open.sync( __filename, 'r+' ); - * if ( fd instanceof Error ) { - * throw fd; - * } - * closeSync( fd ); - */ - sync( path: string | Buffer, flags?: string | number, mode?: number ): number | Error; -} - -/** -* Asynchronously opens a file. -* -* @param path - file path -* @param flags - file system flags (default: 'r') -* @param mode - file mode (default: 0o666) -* @param clbk - callback to invoke after opening a file -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* var fd = open.sync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -declare var open: Open; - - -// EXPORTS // - -export = open; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 9e3afbc..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/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var r=t(Object.freeze({__proto__:null,default:{}})),n="r",o=438,c=r.open;function u(e,t,r,u){var i=arguments.length;return 2===i?c(e,n,o,t):3===i?c(e,t,o,r):void c(e,t,r,u)}var i=r.openSync;function s(e,t,r){var c,u;c=arguments.length;try{u=1===c?i(e,n,o):i(e,t,2===c?o:r)}catch(e){return e}return u}e(u,"sync",s);export{u as default,s as sync}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 0d9f33f..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;0nBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAEzB,CAAC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 34bd866..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 9f77200dd02f2f34d1bd238f2e9bd3b82b6d1df8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 01:25:15 +0000 Subject: [PATCH 098/113] 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 | 55 +- SECURITY.md | 5 - benchmark/benchmark.js | 77 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 65 - docs/types/test.ts | 129 - examples/index.js | 56 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/defaults.json | 4 - lib/index.js | 63 - lib/main.js | 64 - lib/sync.js | 68 - package.json | 58 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 38 - test/test.main.js | 110 - test/test.sync.js | 83 - 47 files changed, 4876 insertions(+), 4286 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/defaults.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/sync.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.sync.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 e2702aa..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-08-01T00:49:12.886Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index a3a4470..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/fs/open) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 7617ad3..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/fs/open) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 d7fc8a0..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: '14 2 * * 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 + + ```
@@ -225,7 +222,7 @@ function onOpen( error, fd ) { ## 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]. @@ -292,11 +289,11 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close +[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close/tree/esm -[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists +[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists/tree/esm -[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file +[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file/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 503cc81..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,77 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var closeSync = require( '@stdlib/fs-close' ).sync; -var pkg = require( './../package.json' ).name; -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return open( __filename, 'r+', done ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function done( error, fd ) { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - if ( error ) { - b.fail( error.message ); - } - next(); - } -}); - -bench( pkg+':sync', function benchmark( b ) { - var fd; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - fd = open.sync( __filename, 'r+' ); - if ( fd instanceof Error ) { - b.fail( fd.message ); - } else { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - } - } - b.toc(); - if ( fd instanceof Error ) { - b.fail( 'something went wrong' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index da1ba5f..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/fs/open" -%% click B href "https://github.com/stdlib-js/fs-open/tree/main" -%% click C href "https://github.com/stdlib-js/fs-open/tree/production" -%% click D href "https://github.com/stdlib-js/fs-open/tree/esm" -%% click E href "https://github.com/stdlib-js/fs-open/tree/deno" -%% click F href "https://github.com/stdlib-js/fs-open/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/fs/open -[production-url]: https://github.com/stdlib-js/fs-open/tree/production -[deno-url]: https://github.com/stdlib-js/fs-open/tree/deno -[deno-readme]: https://github.com/stdlib-js/fs-open/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/fs-open/tree/umd -[umd-readme]: https://github.com/stdlib-js/fs-open/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/fs-open/tree/esm -[esm-readme]: https://github.com/stdlib-js/fs-open/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 3e10601..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import open from '../docs/types/index'; -export = open; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 5358415..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var u=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var i=u(function(b,y){y.exports={flags:"r",mode:438}});var d=u(function(j,f){ -var a=require("fs").open,o=i();function p(r,e,t,s){var n=arguments.length;if(n===2)return a(r,o.flags,o.mode,e);if(n===3)return a(r,e,o.mode,t);a(r,e,t,s)}f.exports=p -});var m=u(function(k,l){ -var c=require("fs").openSync,v=i();function x(r,e,t){var s,n;s=arguments.length;try{s===1?n=c(r,v.flags,v.mode):s===2?n=c(r,e,v.mode):n=c(r,e,t)}catch(g){return g}return n}l.exports=x -});var S=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),q=d(),O=m();S(q,"sync",O);module.exports=q; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 65b6278..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/main.js", "../lib/sync.js", "../lib/index.js"], - "sourcesContent": ["{\n\t\"flags\": \"r\",\n\t\"mode\": 438\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var open = require( '@stdlib/fs-open' );\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nmodule.exports = open;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nmodule.exports = openSync;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var open = require( '@stdlib/fs-open' );\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var openSync = require( '@stdlib/fs-open' ).sync;\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar sync = require( './sync.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,CAAAA,EAAA,SACC,MAAS,IACT,KAAQ,GACT,ICHA,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAK,QAAS,IAAK,EAAE,KACrBC,EAAW,IA0Bf,SAASC,EAAMC,EAAMC,EAAOC,EAAMC,EAAO,CACxC,IAAIC,EAAQ,UAAU,OACtB,GAAKA,IAAU,EACd,OAAOP,EAAIG,EAAMF,EAAS,MAAOA,EAAS,KAAMG,CAAM,EAEvD,GAAKG,IAAU,EACd,OAAOP,EAAIG,EAAMC,EAAOH,EAAS,KAAMI,CAAK,EAE7CL,EAAIG,EAAMC,EAAOC,EAAMC,CAAK,CAC7B,CAKAP,EAAO,QAAUG,IC/DjB,IAAAM,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAO,QAAS,IAAK,EAAE,SACvBC,EAAW,IAsBf,SAASC,EAAUC,EAAMC,EAAOC,EAAO,CACtC,IAAIC,EACAC,EAEJD,EAAQ,UAAU,OAClB,GAAI,CACEA,IAAU,EACdC,EAAKP,EAAMG,EAAMF,EAAS,MAAOA,EAAS,IAAK,EACpCK,IAAU,EACrBC,EAAKP,EAAMG,EAAMC,EAAOH,EAAS,IAAK,EAEtCM,EAAKP,EAAMG,EAAMC,EAAOC,CAAK,CAE/B,OAAUG,EAAM,CACf,OAAOA,CACR,CACA,OAAOD,CACR,CAKAR,EAAO,QAAUG,ICjBjB,IAAIO,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAO,IAKXF,EAAaC,EAAM,OAAQC,CAAK,EAKhC,OAAO,QAAUD", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_main", "__commonJSMin", "exports", "module", "op", "defaults", "open", "path", "flags", "mode", "clbk", "nargs", "require_sync", "__commonJSMin", "exports", "module", "open", "defaults", "openSync", "path", "flags", "mode", "nargs", "fd", "err", "setReadOnly", "main", "sync"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4cbf7ac..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,65 +0,0 @@ - -{{alias}}( path[, flags[, mode]], clbk ) - Asynchronously opens a file. - - Some characters, such as <>:"/\|?*, are reserved under Windows. - Under NTFS, if the path contains a colon, Node.js will open a file system - stream. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - clbk: Function - Callback to invoke upon opening a file. - - Examples - -------- - > function onOpen( error, fd ) { - ... if ( error ) { - ... console.error( error.message ); - ... } else { - ... {{alias:@stdlib/fs/close}}.sync( fd ); - ... } - ... }; - > {{alias}}( './beep/boop.txt', onOpen ); - - -{{alias}}.sync( path[, flags[, mode]] ) - Synchronously opens a file. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - Returns - ------- - fd: Error|integer - File descriptor. - - Examples - -------- - > var fd = {{alias}}.sync( './beep/boop.txt' ); - > if ( !{{alias:@stdlib/assert/is-error}}( fd ) ) { {{alias:@stdlib/fs/close}}.sync( fd ); }; - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 67907a2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,129 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 open = require( './index' ); - -const done = ( error: Error, fd: number ) => { - if ( error || !fd ) { - throw error; - } -}; - - -// TESTS // - -// The function does not have a return value... -{ - open( '/path/to/beepboop', done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a string... -{ - open( 123, done ); // $ExpectError - open( false, done ); // $ExpectError - open( true, done ); // $ExpectError - open( null, done ); // $ExpectError - open( undefined, done ); // $ExpectError - open( [], done ); // $ExpectError - open( {}, done ); // $ExpectError - open( ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a last argument which is not a function with the expected signature... -{ - open( '/path/to/beepboop', 'abc' ); // $ExpectError - open( '/path/to/beepboop', 123 ); // $ExpectError - open( '/path/to/beepboop', false ); // $ExpectError - open( '/path/to/beepboop', true ); // $ExpectError - open( '/path/to/beepboop', null ); // $ExpectError - open( '/path/to/beepboop', undefined ); // $ExpectError - open( '/path/to/beepboop', [] ); // $ExpectError - open( '/path/to/beepboop', {} ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `flags` argument which is not a string or number... -{ - open( '/path/to/beepboop', false, done ); // $ExpectError - open( '/path/to/beepboop', true, done ); // $ExpectError - open( '/path/to/beepboop', null, done ); // $ExpectError - open( '/path/to/beepboop', undefined, done ); // $ExpectError - open( '/path/to/beepboop', [], done ); // $ExpectError - open( '/path/to/beepboop', {}, done ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` argument which is not a number... -{ - open( '/path/to/beepboop', 'r+', 'abc', done ); // $ExpectError - open( '/path/to/beepboop', 'r+', false, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', true, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', null, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', undefined, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', [], done ); // $ExpectError - open( '/path/to/beepboop', 'r+', {}, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - open(); // $ExpectError - open( 'C:\\foo\\bar\\baz' ); // $ExpectError -} - -// Attached to main export is a `sync` method which returns a number or an error... -{ - open.sync( '/path/to/beepboop' ); // $ExpectType number | Error -} - -// The compiler throws an error if the `sync` method is provided a first argument which is not a string... -{ - open.sync( 123 ); // $ExpectError - open.sync( false ); // $ExpectError - open.sync( true ); // $ExpectError - open.sync( null ); // $ExpectError - open.sync( undefined ); // $ExpectError - open.sync( [] ); // $ExpectError - open.sync( {} ); // $ExpectError - open.sync( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a second argument which is not a string or number... -{ - open.sync( '/path/to/beepboop', false ); // $ExpectError - open.sync( '/path/to/beepboop', true ); // $ExpectError - open.sync( '/path/to/beepboop', null ); // $ExpectError - open.sync( '/path/to/beepboop', [] ); // $ExpectError - open.sync( '/path/to/beepboop', {} ); // $ExpectError - open.sync( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a third argument which is not a number... -{ - open.sync( '/path/to/beepboop', 'r+', false ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', true ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', null ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', [] ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', {} ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided an unsupported number of arguments... -{ - open.sync(); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 71359fe..0000000 --- a/examples/index.js +++ /dev/null @@ -1,56 +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. -*/ - -'use strict'; - -var closeSync = require( '@stdlib/fs-close' ).sync; -var isError = require( '@stdlib/assert-is-error' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - -/* Sync */ - -var fd = open.sync( __filename, 'r+' ); -// returns - -console.log( isError( fd ) ); -// => false - -closeSync( fd ); - -fd = open.sync( 'beepboop' ); -// returns - -console.log( isError( fd ) ); -// => true - -/* Async */ - -open( __filename, onOpen ); -open( 'beepboop', onOpen ); - -function onOpen( error, fd ) { - if ( error ) { - if ( error.code === 'ENOENT' ) { - console.error( 'File does not exist.' ); - } else { - throw error; - } - } else { - closeSync( fd ); - } -} 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..9e3afbc --- /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/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var r=t(Object.freeze({__proto__:null,default:{}})),n="r",o=438,c=r.open;function u(e,t,r,u){var i=arguments.length;return 2===i?c(e,n,o,t):3===i?c(e,t,o,r):void c(e,t,r,u)}var i=r.openSync;function s(e,t,r){var c,u;c=arguments.length;try{u=1===c?i(e,n,o):i(e,t,2===c?o:r)}catch(e){return e}return u}e(u,"sync",s);export{u as default,s as sync}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..0d9f33f --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;0nBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAEzB,CAAC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index cb174b7..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "flags": "r", - "mode": 438 -} diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 8edd6de..0000000 --- a/lib/index.js +++ /dev/null @@ -1,63 +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. -*/ - -'use strict'; - -/** -* Open a file. -* -* @module @stdlib/fs-open -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var openSync = require( '@stdlib/fs-open' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var sync = require( './sync.js' ); - - -// MAIN // - -setReadOnly( main, 'sync', sync ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index feb5171..0000000 --- a/lib/main.js +++ /dev/null @@ -1,64 +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. -*/ - -'use strict'; - -// MODULES // - -var op = require( 'fs' ).open; -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Asynchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @param {Function} clbk - callback to invoke after opening a file -* @returns {void} -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -*/ -function open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare - var nargs = arguments.length; - if ( nargs === 2 ) { - return op( path, defaults.flags, defaults.mode, flags ); - } - if ( nargs === 3 ) { - return op( path, flags, defaults.mode, mode ); - } - op( path, flags, mode, clbk ); -} - - -// EXPORTS // - -module.exports = open; diff --git a/lib/sync.js b/lib/sync.js deleted file mode 100644 index d8d2e00..0000000 --- a/lib/sync.js +++ /dev/null @@ -1,68 +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. -*/ - -'use strict'; - -// MODULES // - -var open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Synchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @returns {(integer|Error)} file descriptor or an error -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -function openSync( path, flags, mode ) { - var nargs; - var fd; - - nargs = arguments.length; - try { - if ( nargs === 1 ) { - fd = open( path, defaults.flags, defaults.mode ); - } else if ( nargs === 2 ) { - fd = open( path, flags, defaults.mode ); - } else { - fd = open( path, flags, mode ); - } - } catch ( err ) { - return err; - } - return fd; -} - - -// EXPORTS // - -module.exports = openSync; diff --git a/package.json b/package.json index e20fa42..c2272c8 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Open a file.", "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/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.2.2", - "@stdlib/assert-is-error": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/fs-close": "^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", "stdfs", @@ -82,4 +30,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..34bd866 --- /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 3c47135..0000000 --- a/test/test.js +++ /dev/null @@ -1,38 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is a function to open a file synchronously', function test( t ) { - t.equal( typeof open.sync, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 33b938f..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,110 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/main.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - open( __filename, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - open( __filename, 'r+', onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - open( __filename, 'r+', 438, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - open( 'beepboopbapbop', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', 438, onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); diff --git a/test/test.sync.js b/test/test.sync.js deleted file mode 100644 index 56d7b23..0000000 --- a/test/test.sync.js +++ /dev/null @@ -1,83 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/sync.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - var fd = open( __filename ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - var fd = open( __filename, 'r+' ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - var fd = open( __filename, 'r+', 438 ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - var fd = open( 'beepboopbapbop' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+', 438 ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); From fecb4ebefdd52cc9f8eb5c0c1190403675abec70 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Aug 2024 15:33:25 +0000 Subject: [PATCH 099/113] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index acacb8b..e20fa42 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.2.2", @@ -81,4 +82,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 54a944e9f8ff45b04691d8592bae5c35324b49a7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Aug 2024 15:49:32 +0000 Subject: [PATCH 100/113] Remove files --- index.d.ts | 150 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4997 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 dddbd0c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,150 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Buffer } from 'buffer'; - -/** -* Callback invoked after opening a file. -* -* @param err - error argument -* @param fd - file descriptor -*/ -type Callback = ( err: Error, fd: number ) => void; - -/** -* Interface for opening a file. -*/ -interface Open { - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', 438, onOpen ); - */ - ( path: string | Buffer, flags: string | number, mode: number, clbk: Callback ): void; - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', onOpen ); - */ - ( path: string | Buffer, flags: string | number, clbk: Callback ): void; - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, onOpen ); - */ - ( path: string | Buffer, clbk: Callback ): void; - - /** - * Synchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @returns file descriptor or an error - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * var fd = open.sync( __filename, 'r+' ); - * if ( fd instanceof Error ) { - * throw fd; - * } - * closeSync( fd ); - */ - sync( path: string | Buffer, flags?: string | number, mode?: number ): number | Error; -} - -/** -* Asynchronously opens a file. -* -* @param path - file path -* @param flags - file system flags (default: 'r') -* @param mode - file mode (default: 0o666) -* @param clbk - callback to invoke after opening a file -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* var fd = open.sync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -declare var open: Open; - - -// EXPORTS // - -export = open; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 9e3afbc..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/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var r=t(Object.freeze({__proto__:null,default:{}})),n="r",o=438,c=r.open;function u(e,t,r,u){var i=arguments.length;return 2===i?c(e,n,o,t):3===i?c(e,t,o,r):void c(e,t,r,u)}var i=r.openSync;function s(e,t,r){var c,u;c=arguments.length;try{u=1===c?i(e,n,o):i(e,t,2===c?o:r)}catch(e){return e}return u}e(u,"sync",s);export{u as default,s as sync}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 0d9f33f..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;0nBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAEzB,CAAC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 34bd866..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 9bd10b55189f226b04766210a58ab4097ce0fdce Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Aug 2024 15:49:45 +0000 Subject: [PATCH 101/113] 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 | 197 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 55 +- SECURITY.md | 5 - benchmark/benchmark.js | 77 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 65 - docs/types/test.ts | 129 - examples/index.js | 56 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/defaults.json | 4 - lib/index.js | 63 - lib/main.js | 64 - lib/sync.js | 68 - package.json | 58 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 38 - test/test.main.js | 110 - test/test.sync.js | 83 - 47 files changed, 4876 insertions(+), 4325 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/defaults.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/sync.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.sync.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 6c999c4..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-08-03T15:27:55.644Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index a3a4470..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/fs/open) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 7617ad3..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/fs/open) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 d7fc8a0..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: '14 2 * * 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 + + ```
@@ -225,7 +222,7 @@ function onOpen( error, fd ) { ## 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]. @@ -292,11 +289,11 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close +[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close/tree/esm -[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists +[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists/tree/esm -[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file +[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file/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 503cc81..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,77 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var closeSync = require( '@stdlib/fs-close' ).sync; -var pkg = require( './../package.json' ).name; -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return open( __filename, 'r+', done ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function done( error, fd ) { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - if ( error ) { - b.fail( error.message ); - } - next(); - } -}); - -bench( pkg+':sync', function benchmark( b ) { - var fd; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - fd = open.sync( __filename, 'r+' ); - if ( fd instanceof Error ) { - b.fail( fd.message ); - } else { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - } - } - b.toc(); - if ( fd instanceof Error ) { - b.fail( 'something went wrong' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index da1ba5f..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/fs/open" -%% click B href "https://github.com/stdlib-js/fs-open/tree/main" -%% click C href "https://github.com/stdlib-js/fs-open/tree/production" -%% click D href "https://github.com/stdlib-js/fs-open/tree/esm" -%% click E href "https://github.com/stdlib-js/fs-open/tree/deno" -%% click F href "https://github.com/stdlib-js/fs-open/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/fs/open -[production-url]: https://github.com/stdlib-js/fs-open/tree/production -[deno-url]: https://github.com/stdlib-js/fs-open/tree/deno -[deno-readme]: https://github.com/stdlib-js/fs-open/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/fs-open/tree/umd -[umd-readme]: https://github.com/stdlib-js/fs-open/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/fs-open/tree/esm -[esm-readme]: https://github.com/stdlib-js/fs-open/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 3e10601..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import open from '../docs/types/index'; -export = open; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 5358415..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var u=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var i=u(function(b,y){y.exports={flags:"r",mode:438}});var d=u(function(j,f){ -var a=require("fs").open,o=i();function p(r,e,t,s){var n=arguments.length;if(n===2)return a(r,o.flags,o.mode,e);if(n===3)return a(r,e,o.mode,t);a(r,e,t,s)}f.exports=p -});var m=u(function(k,l){ -var c=require("fs").openSync,v=i();function x(r,e,t){var s,n;s=arguments.length;try{s===1?n=c(r,v.flags,v.mode):s===2?n=c(r,e,v.mode):n=c(r,e,t)}catch(g){return g}return n}l.exports=x -});var S=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),q=d(),O=m();S(q,"sync",O);module.exports=q; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 65b6278..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/main.js", "../lib/sync.js", "../lib/index.js"], - "sourcesContent": ["{\n\t\"flags\": \"r\",\n\t\"mode\": 438\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var open = require( '@stdlib/fs-open' );\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nmodule.exports = open;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nmodule.exports = openSync;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var open = require( '@stdlib/fs-open' );\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var openSync = require( '@stdlib/fs-open' ).sync;\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar sync = require( './sync.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,CAAAA,EAAA,SACC,MAAS,IACT,KAAQ,GACT,ICHA,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAK,QAAS,IAAK,EAAE,KACrBC,EAAW,IA0Bf,SAASC,EAAMC,EAAMC,EAAOC,EAAMC,EAAO,CACxC,IAAIC,EAAQ,UAAU,OACtB,GAAKA,IAAU,EACd,OAAOP,EAAIG,EAAMF,EAAS,MAAOA,EAAS,KAAMG,CAAM,EAEvD,GAAKG,IAAU,EACd,OAAOP,EAAIG,EAAMC,EAAOH,EAAS,KAAMI,CAAK,EAE7CL,EAAIG,EAAMC,EAAOC,EAAMC,CAAK,CAC7B,CAKAP,EAAO,QAAUG,IC/DjB,IAAAM,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAO,QAAS,IAAK,EAAE,SACvBC,EAAW,IAsBf,SAASC,EAAUC,EAAMC,EAAOC,EAAO,CACtC,IAAIC,EACAC,EAEJD,EAAQ,UAAU,OAClB,GAAI,CACEA,IAAU,EACdC,EAAKP,EAAMG,EAAMF,EAAS,MAAOA,EAAS,IAAK,EACpCK,IAAU,EACrBC,EAAKP,EAAMG,EAAMC,EAAOH,EAAS,IAAK,EAEtCM,EAAKP,EAAMG,EAAMC,EAAOC,CAAK,CAE/B,OAAUG,EAAM,CACf,OAAOA,CACR,CACA,OAAOD,CACR,CAKAR,EAAO,QAAUG,ICjBjB,IAAIO,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAO,IAKXF,EAAaC,EAAM,OAAQC,CAAK,EAKhC,OAAO,QAAUD", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_main", "__commonJSMin", "exports", "module", "op", "defaults", "open", "path", "flags", "mode", "clbk", "nargs", "require_sync", "__commonJSMin", "exports", "module", "open", "defaults", "openSync", "path", "flags", "mode", "nargs", "fd", "err", "setReadOnly", "main", "sync"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4cbf7ac..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,65 +0,0 @@ - -{{alias}}( path[, flags[, mode]], clbk ) - Asynchronously opens a file. - - Some characters, such as <>:"/\|?*, are reserved under Windows. - Under NTFS, if the path contains a colon, Node.js will open a file system - stream. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - clbk: Function - Callback to invoke upon opening a file. - - Examples - -------- - > function onOpen( error, fd ) { - ... if ( error ) { - ... console.error( error.message ); - ... } else { - ... {{alias:@stdlib/fs/close}}.sync( fd ); - ... } - ... }; - > {{alias}}( './beep/boop.txt', onOpen ); - - -{{alias}}.sync( path[, flags[, mode]] ) - Synchronously opens a file. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - Returns - ------- - fd: Error|integer - File descriptor. - - Examples - -------- - > var fd = {{alias}}.sync( './beep/boop.txt' ); - > if ( !{{alias:@stdlib/assert/is-error}}( fd ) ) { {{alias:@stdlib/fs/close}}.sync( fd ); }; - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 67907a2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,129 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 open = require( './index' ); - -const done = ( error: Error, fd: number ) => { - if ( error || !fd ) { - throw error; - } -}; - - -// TESTS // - -// The function does not have a return value... -{ - open( '/path/to/beepboop', done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a string... -{ - open( 123, done ); // $ExpectError - open( false, done ); // $ExpectError - open( true, done ); // $ExpectError - open( null, done ); // $ExpectError - open( undefined, done ); // $ExpectError - open( [], done ); // $ExpectError - open( {}, done ); // $ExpectError - open( ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a last argument which is not a function with the expected signature... -{ - open( '/path/to/beepboop', 'abc' ); // $ExpectError - open( '/path/to/beepboop', 123 ); // $ExpectError - open( '/path/to/beepboop', false ); // $ExpectError - open( '/path/to/beepboop', true ); // $ExpectError - open( '/path/to/beepboop', null ); // $ExpectError - open( '/path/to/beepboop', undefined ); // $ExpectError - open( '/path/to/beepboop', [] ); // $ExpectError - open( '/path/to/beepboop', {} ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `flags` argument which is not a string or number... -{ - open( '/path/to/beepboop', false, done ); // $ExpectError - open( '/path/to/beepboop', true, done ); // $ExpectError - open( '/path/to/beepboop', null, done ); // $ExpectError - open( '/path/to/beepboop', undefined, done ); // $ExpectError - open( '/path/to/beepboop', [], done ); // $ExpectError - open( '/path/to/beepboop', {}, done ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` argument which is not a number... -{ - open( '/path/to/beepboop', 'r+', 'abc', done ); // $ExpectError - open( '/path/to/beepboop', 'r+', false, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', true, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', null, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', undefined, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', [], done ); // $ExpectError - open( '/path/to/beepboop', 'r+', {}, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - open(); // $ExpectError - open( 'C:\\foo\\bar\\baz' ); // $ExpectError -} - -// Attached to main export is a `sync` method which returns a number or an error... -{ - open.sync( '/path/to/beepboop' ); // $ExpectType number | Error -} - -// The compiler throws an error if the `sync` method is provided a first argument which is not a string... -{ - open.sync( 123 ); // $ExpectError - open.sync( false ); // $ExpectError - open.sync( true ); // $ExpectError - open.sync( null ); // $ExpectError - open.sync( undefined ); // $ExpectError - open.sync( [] ); // $ExpectError - open.sync( {} ); // $ExpectError - open.sync( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a second argument which is not a string or number... -{ - open.sync( '/path/to/beepboop', false ); // $ExpectError - open.sync( '/path/to/beepboop', true ); // $ExpectError - open.sync( '/path/to/beepboop', null ); // $ExpectError - open.sync( '/path/to/beepboop', [] ); // $ExpectError - open.sync( '/path/to/beepboop', {} ); // $ExpectError - open.sync( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a third argument which is not a number... -{ - open.sync( '/path/to/beepboop', 'r+', false ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', true ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', null ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', [] ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', {} ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided an unsupported number of arguments... -{ - open.sync(); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 71359fe..0000000 --- a/examples/index.js +++ /dev/null @@ -1,56 +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. -*/ - -'use strict'; - -var closeSync = require( '@stdlib/fs-close' ).sync; -var isError = require( '@stdlib/assert-is-error' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - -/* Sync */ - -var fd = open.sync( __filename, 'r+' ); -// returns - -console.log( isError( fd ) ); -// => false - -closeSync( fd ); - -fd = open.sync( 'beepboop' ); -// returns - -console.log( isError( fd ) ); -// => true - -/* Async */ - -open( __filename, onOpen ); -open( 'beepboop', onOpen ); - -function onOpen( error, fd ) { - if ( error ) { - if ( error.code === 'ENOENT' ) { - console.error( 'File does not exist.' ); - } else { - throw error; - } - } else { - closeSync( fd ); - } -} 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..9e3afbc --- /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/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var r=t(Object.freeze({__proto__:null,default:{}})),n="r",o=438,c=r.open;function u(e,t,r,u){var i=arguments.length;return 2===i?c(e,n,o,t):3===i?c(e,t,o,r):void c(e,t,r,u)}var i=r.openSync;function s(e,t,r){var c,u;c=arguments.length;try{u=1===c?i(e,n,o):i(e,t,2===c?o:r)}catch(e){return e}return u}e(u,"sync",s);export{u as default,s as sync}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..0d9f33f --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;0nBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAEzB,CAAC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index cb174b7..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "flags": "r", - "mode": 438 -} diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 8edd6de..0000000 --- a/lib/index.js +++ /dev/null @@ -1,63 +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. -*/ - -'use strict'; - -/** -* Open a file. -* -* @module @stdlib/fs-open -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var openSync = require( '@stdlib/fs-open' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var sync = require( './sync.js' ); - - -// MAIN // - -setReadOnly( main, 'sync', sync ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index feb5171..0000000 --- a/lib/main.js +++ /dev/null @@ -1,64 +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. -*/ - -'use strict'; - -// MODULES // - -var op = require( 'fs' ).open; -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Asynchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @param {Function} clbk - callback to invoke after opening a file -* @returns {void} -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -*/ -function open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare - var nargs = arguments.length; - if ( nargs === 2 ) { - return op( path, defaults.flags, defaults.mode, flags ); - } - if ( nargs === 3 ) { - return op( path, flags, defaults.mode, mode ); - } - op( path, flags, mode, clbk ); -} - - -// EXPORTS // - -module.exports = open; diff --git a/lib/sync.js b/lib/sync.js deleted file mode 100644 index d8d2e00..0000000 --- a/lib/sync.js +++ /dev/null @@ -1,68 +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. -*/ - -'use strict'; - -// MODULES // - -var open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Synchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @returns {(integer|Error)} file descriptor or an error -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -function openSync( path, flags, mode ) { - var nargs; - var fd; - - nargs = arguments.length; - try { - if ( nargs === 1 ) { - fd = open( path, defaults.flags, defaults.mode ); - } else if ( nargs === 2 ) { - fd = open( path, flags, defaults.mode ); - } else { - fd = open( path, flags, mode ); - } - } catch ( err ) { - return err; - } - return fd; -} - - -// EXPORTS // - -module.exports = openSync; diff --git a/package.json b/package.json index e20fa42..c2272c8 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Open a file.", "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/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.2.2", - "@stdlib/assert-is-error": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/fs-close": "^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", "stdfs", @@ -82,4 +30,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..34bd866 --- /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 3c47135..0000000 --- a/test/test.js +++ /dev/null @@ -1,38 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is a function to open a file synchronously', function test( t ) { - t.equal( typeof open.sync, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 33b938f..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,110 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/main.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - open( __filename, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - open( __filename, 'r+', onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - open( __filename, 'r+', 438, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - open( 'beepboopbapbop', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', 438, onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); diff --git a/test/test.sync.js b/test/test.sync.js deleted file mode 100644 index 56d7b23..0000000 --- a/test/test.sync.js +++ /dev/null @@ -1,83 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/sync.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - var fd = open( __filename ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - var fd = open( __filename, 'r+' ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - var fd = open( __filename, 'r+', 438 ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - var fd = open( 'beepboopbapbop' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+', 438 ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); From 34f8348ce79529da4d1fdea8667f0a9286383f61 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 01:02:17 +0000 Subject: [PATCH 102/113] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index acacb8b..e20fa42 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.2.2", @@ -81,4 +82,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From eadd882af656ad84144f1e15adf40e576a74e0a2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 01:33:37 +0000 Subject: [PATCH 103/113] Remove files --- index.d.ts | 150 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4997 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 dddbd0c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,150 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Buffer } from 'buffer'; - -/** -* Callback invoked after opening a file. -* -* @param err - error argument -* @param fd - file descriptor -*/ -type Callback = ( err: Error, fd: number ) => void; - -/** -* Interface for opening a file. -*/ -interface Open { - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', 438, onOpen ); - */ - ( path: string | Buffer, flags: string | number, mode: number, clbk: Callback ): void; - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', onOpen ); - */ - ( path: string | Buffer, flags: string | number, clbk: Callback ): void; - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, onOpen ); - */ - ( path: string | Buffer, clbk: Callback ): void; - - /** - * Synchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @returns file descriptor or an error - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * var fd = open.sync( __filename, 'r+' ); - * if ( fd instanceof Error ) { - * throw fd; - * } - * closeSync( fd ); - */ - sync( path: string | Buffer, flags?: string | number, mode?: number ): number | Error; -} - -/** -* Asynchronously opens a file. -* -* @param path - file path -* @param flags - file system flags (default: 'r') -* @param mode - file mode (default: 0o666) -* @param clbk - callback to invoke after opening a file -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* var fd = open.sync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -declare var open: Open; - - -// EXPORTS // - -export = open; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 9e3afbc..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/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var r=t(Object.freeze({__proto__:null,default:{}})),n="r",o=438,c=r.open;function u(e,t,r,u){var i=arguments.length;return 2===i?c(e,n,o,t):3===i?c(e,t,o,r):void c(e,t,r,u)}var i=r.openSync;function s(e,t,r){var c,u;c=arguments.length;try{u=1===c?i(e,n,o):i(e,t,2===c?o:r)}catch(e){return e}return u}e(u,"sync",s);export{u as default,s as sync}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 0d9f33f..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;0nBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAEzB,CAAC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 34bd866..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 6de2a83333e26f9ef786339ff0c87e8f326dadbb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 01:33:50 +0000 Subject: [PATCH 104/113] 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 | 196 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 55 +- SECURITY.md | 5 - benchmark/benchmark.js | 77 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 65 - docs/types/test.ts | 129 - examples/index.js | 56 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/defaults.json | 4 - lib/index.js | 63 - lib/main.js | 64 - lib/sync.js | 68 - package.json | 58 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 38 - test/test.main.js | 110 - test/test.sync.js | 83 - 47 files changed, 4876 insertions(+), 4324 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/defaults.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/sync.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.sync.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 9f593ca..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-09-01T00:55:34.055Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index a3a4470..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/fs/open) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 7617ad3..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/fs/open) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 d7fc8a0..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: '14 2 * * 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 + + ```
@@ -225,7 +222,7 @@ function onOpen( error, fd ) { ## 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]. @@ -292,11 +289,11 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close +[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close/tree/esm -[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists +[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists/tree/esm -[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file +[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file/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 503cc81..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,77 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var closeSync = require( '@stdlib/fs-close' ).sync; -var pkg = require( './../package.json' ).name; -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return open( __filename, 'r+', done ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function done( error, fd ) { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - if ( error ) { - b.fail( error.message ); - } - next(); - } -}); - -bench( pkg+':sync', function benchmark( b ) { - var fd; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - fd = open.sync( __filename, 'r+' ); - if ( fd instanceof Error ) { - b.fail( fd.message ); - } else { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - } - } - b.toc(); - if ( fd instanceof Error ) { - b.fail( 'something went wrong' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index da1ba5f..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/fs/open" -%% click B href "https://github.com/stdlib-js/fs-open/tree/main" -%% click C href "https://github.com/stdlib-js/fs-open/tree/production" -%% click D href "https://github.com/stdlib-js/fs-open/tree/esm" -%% click E href "https://github.com/stdlib-js/fs-open/tree/deno" -%% click F href "https://github.com/stdlib-js/fs-open/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/fs/open -[production-url]: https://github.com/stdlib-js/fs-open/tree/production -[deno-url]: https://github.com/stdlib-js/fs-open/tree/deno -[deno-readme]: https://github.com/stdlib-js/fs-open/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/fs-open/tree/umd -[umd-readme]: https://github.com/stdlib-js/fs-open/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/fs-open/tree/esm -[esm-readme]: https://github.com/stdlib-js/fs-open/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 3e10601..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import open from '../docs/types/index'; -export = open; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 5358415..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var u=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var i=u(function(b,y){y.exports={flags:"r",mode:438}});var d=u(function(j,f){ -var a=require("fs").open,o=i();function p(r,e,t,s){var n=arguments.length;if(n===2)return a(r,o.flags,o.mode,e);if(n===3)return a(r,e,o.mode,t);a(r,e,t,s)}f.exports=p -});var m=u(function(k,l){ -var c=require("fs").openSync,v=i();function x(r,e,t){var s,n;s=arguments.length;try{s===1?n=c(r,v.flags,v.mode):s===2?n=c(r,e,v.mode):n=c(r,e,t)}catch(g){return g}return n}l.exports=x -});var S=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),q=d(),O=m();S(q,"sync",O);module.exports=q; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 65b6278..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/main.js", "../lib/sync.js", "../lib/index.js"], - "sourcesContent": ["{\n\t\"flags\": \"r\",\n\t\"mode\": 438\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var open = require( '@stdlib/fs-open' );\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nmodule.exports = open;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nmodule.exports = openSync;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var open = require( '@stdlib/fs-open' );\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var openSync = require( '@stdlib/fs-open' ).sync;\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar sync = require( './sync.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,CAAAA,EAAA,SACC,MAAS,IACT,KAAQ,GACT,ICHA,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAK,QAAS,IAAK,EAAE,KACrBC,EAAW,IA0Bf,SAASC,EAAMC,EAAMC,EAAOC,EAAMC,EAAO,CACxC,IAAIC,EAAQ,UAAU,OACtB,GAAKA,IAAU,EACd,OAAOP,EAAIG,EAAMF,EAAS,MAAOA,EAAS,KAAMG,CAAM,EAEvD,GAAKG,IAAU,EACd,OAAOP,EAAIG,EAAMC,EAAOH,EAAS,KAAMI,CAAK,EAE7CL,EAAIG,EAAMC,EAAOC,EAAMC,CAAK,CAC7B,CAKAP,EAAO,QAAUG,IC/DjB,IAAAM,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAO,QAAS,IAAK,EAAE,SACvBC,EAAW,IAsBf,SAASC,EAAUC,EAAMC,EAAOC,EAAO,CACtC,IAAIC,EACAC,EAEJD,EAAQ,UAAU,OAClB,GAAI,CACEA,IAAU,EACdC,EAAKP,EAAMG,EAAMF,EAAS,MAAOA,EAAS,IAAK,EACpCK,IAAU,EACrBC,EAAKP,EAAMG,EAAMC,EAAOH,EAAS,IAAK,EAEtCM,EAAKP,EAAMG,EAAMC,EAAOC,CAAK,CAE/B,OAAUG,EAAM,CACf,OAAOA,CACR,CACA,OAAOD,CACR,CAKAR,EAAO,QAAUG,ICjBjB,IAAIO,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAO,IAKXF,EAAaC,EAAM,OAAQC,CAAK,EAKhC,OAAO,QAAUD", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_main", "__commonJSMin", "exports", "module", "op", "defaults", "open", "path", "flags", "mode", "clbk", "nargs", "require_sync", "__commonJSMin", "exports", "module", "open", "defaults", "openSync", "path", "flags", "mode", "nargs", "fd", "err", "setReadOnly", "main", "sync"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4cbf7ac..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,65 +0,0 @@ - -{{alias}}( path[, flags[, mode]], clbk ) - Asynchronously opens a file. - - Some characters, such as <>:"/\|?*, are reserved under Windows. - Under NTFS, if the path contains a colon, Node.js will open a file system - stream. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - clbk: Function - Callback to invoke upon opening a file. - - Examples - -------- - > function onOpen( error, fd ) { - ... if ( error ) { - ... console.error( error.message ); - ... } else { - ... {{alias:@stdlib/fs/close}}.sync( fd ); - ... } - ... }; - > {{alias}}( './beep/boop.txt', onOpen ); - - -{{alias}}.sync( path[, flags[, mode]] ) - Synchronously opens a file. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - Returns - ------- - fd: Error|integer - File descriptor. - - Examples - -------- - > var fd = {{alias}}.sync( './beep/boop.txt' ); - > if ( !{{alias:@stdlib/assert/is-error}}( fd ) ) { {{alias:@stdlib/fs/close}}.sync( fd ); }; - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 67907a2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,129 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 open = require( './index' ); - -const done = ( error: Error, fd: number ) => { - if ( error || !fd ) { - throw error; - } -}; - - -// TESTS // - -// The function does not have a return value... -{ - open( '/path/to/beepboop', done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a string... -{ - open( 123, done ); // $ExpectError - open( false, done ); // $ExpectError - open( true, done ); // $ExpectError - open( null, done ); // $ExpectError - open( undefined, done ); // $ExpectError - open( [], done ); // $ExpectError - open( {}, done ); // $ExpectError - open( ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a last argument which is not a function with the expected signature... -{ - open( '/path/to/beepboop', 'abc' ); // $ExpectError - open( '/path/to/beepboop', 123 ); // $ExpectError - open( '/path/to/beepboop', false ); // $ExpectError - open( '/path/to/beepboop', true ); // $ExpectError - open( '/path/to/beepboop', null ); // $ExpectError - open( '/path/to/beepboop', undefined ); // $ExpectError - open( '/path/to/beepboop', [] ); // $ExpectError - open( '/path/to/beepboop', {} ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `flags` argument which is not a string or number... -{ - open( '/path/to/beepboop', false, done ); // $ExpectError - open( '/path/to/beepboop', true, done ); // $ExpectError - open( '/path/to/beepboop', null, done ); // $ExpectError - open( '/path/to/beepboop', undefined, done ); // $ExpectError - open( '/path/to/beepboop', [], done ); // $ExpectError - open( '/path/to/beepboop', {}, done ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` argument which is not a number... -{ - open( '/path/to/beepboop', 'r+', 'abc', done ); // $ExpectError - open( '/path/to/beepboop', 'r+', false, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', true, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', null, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', undefined, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', [], done ); // $ExpectError - open( '/path/to/beepboop', 'r+', {}, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - open(); // $ExpectError - open( 'C:\\foo\\bar\\baz' ); // $ExpectError -} - -// Attached to main export is a `sync` method which returns a number or an error... -{ - open.sync( '/path/to/beepboop' ); // $ExpectType number | Error -} - -// The compiler throws an error if the `sync` method is provided a first argument which is not a string... -{ - open.sync( 123 ); // $ExpectError - open.sync( false ); // $ExpectError - open.sync( true ); // $ExpectError - open.sync( null ); // $ExpectError - open.sync( undefined ); // $ExpectError - open.sync( [] ); // $ExpectError - open.sync( {} ); // $ExpectError - open.sync( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a second argument which is not a string or number... -{ - open.sync( '/path/to/beepboop', false ); // $ExpectError - open.sync( '/path/to/beepboop', true ); // $ExpectError - open.sync( '/path/to/beepboop', null ); // $ExpectError - open.sync( '/path/to/beepboop', [] ); // $ExpectError - open.sync( '/path/to/beepboop', {} ); // $ExpectError - open.sync( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a third argument which is not a number... -{ - open.sync( '/path/to/beepboop', 'r+', false ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', true ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', null ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', [] ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', {} ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided an unsupported number of arguments... -{ - open.sync(); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 71359fe..0000000 --- a/examples/index.js +++ /dev/null @@ -1,56 +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. -*/ - -'use strict'; - -var closeSync = require( '@stdlib/fs-close' ).sync; -var isError = require( '@stdlib/assert-is-error' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - -/* Sync */ - -var fd = open.sync( __filename, 'r+' ); -// returns - -console.log( isError( fd ) ); -// => false - -closeSync( fd ); - -fd = open.sync( 'beepboop' ); -// returns - -console.log( isError( fd ) ); -// => true - -/* Async */ - -open( __filename, onOpen ); -open( 'beepboop', onOpen ); - -function onOpen( error, fd ) { - if ( error ) { - if ( error.code === 'ENOENT' ) { - console.error( 'File does not exist.' ); - } else { - throw error; - } - } else { - closeSync( fd ); - } -} 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..9e3afbc --- /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/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var r=t(Object.freeze({__proto__:null,default:{}})),n="r",o=438,c=r.open;function u(e,t,r,u){var i=arguments.length;return 2===i?c(e,n,o,t):3===i?c(e,t,o,r):void c(e,t,r,u)}var i=r.openSync;function s(e,t,r){var c,u;c=arguments.length;try{u=1===c?i(e,n,o):i(e,t,2===c?o:r)}catch(e){return e}return u}e(u,"sync",s);export{u as default,s as sync}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..0d9f33f --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;0nBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAEzB,CAAC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index cb174b7..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "flags": "r", - "mode": 438 -} diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 8edd6de..0000000 --- a/lib/index.js +++ /dev/null @@ -1,63 +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. -*/ - -'use strict'; - -/** -* Open a file. -* -* @module @stdlib/fs-open -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var openSync = require( '@stdlib/fs-open' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var sync = require( './sync.js' ); - - -// MAIN // - -setReadOnly( main, 'sync', sync ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index feb5171..0000000 --- a/lib/main.js +++ /dev/null @@ -1,64 +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. -*/ - -'use strict'; - -// MODULES // - -var op = require( 'fs' ).open; -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Asynchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @param {Function} clbk - callback to invoke after opening a file -* @returns {void} -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -*/ -function open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare - var nargs = arguments.length; - if ( nargs === 2 ) { - return op( path, defaults.flags, defaults.mode, flags ); - } - if ( nargs === 3 ) { - return op( path, flags, defaults.mode, mode ); - } - op( path, flags, mode, clbk ); -} - - -// EXPORTS // - -module.exports = open; diff --git a/lib/sync.js b/lib/sync.js deleted file mode 100644 index d8d2e00..0000000 --- a/lib/sync.js +++ /dev/null @@ -1,68 +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. -*/ - -'use strict'; - -// MODULES // - -var open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Synchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @returns {(integer|Error)} file descriptor or an error -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -function openSync( path, flags, mode ) { - var nargs; - var fd; - - nargs = arguments.length; - try { - if ( nargs === 1 ) { - fd = open( path, defaults.flags, defaults.mode ); - } else if ( nargs === 2 ) { - fd = open( path, flags, defaults.mode ); - } else { - fd = open( path, flags, mode ); - } - } catch ( err ) { - return err; - } - return fd; -} - - -// EXPORTS // - -module.exports = openSync; diff --git a/package.json b/package.json index e20fa42..c2272c8 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Open a file.", "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/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.2.2", - "@stdlib/assert-is-error": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/fs-close": "^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", "stdfs", @@ -82,4 +30,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..34bd866 --- /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 3c47135..0000000 --- a/test/test.js +++ /dev/null @@ -1,38 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is a function to open a file synchronously', function test( t ) { - t.equal( typeof open.sync, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 33b938f..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,110 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/main.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - open( __filename, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - open( __filename, 'r+', onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - open( __filename, 'r+', 438, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - open( 'beepboopbapbop', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', 438, onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); diff --git a/test/test.sync.js b/test/test.sync.js deleted file mode 100644 index 56d7b23..0000000 --- a/test/test.sync.js +++ /dev/null @@ -1,83 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/sync.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - var fd = open( __filename ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - var fd = open( __filename, 'r+' ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - var fd = open( __filename, 'r+', 438 ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - var fd = open( 'beepboopbapbop' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+', 438 ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); From 7d5c7cdc8ccd67e93cc2930465f24530d24b44ce Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 01:02:15 +0000 Subject: [PATCH 105/113] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index acacb8b..e20fa42 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.2.2", @@ -81,4 +82,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From bee22f9e259d21981233046a2ea16e707d35d3ab Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 01:28:47 +0000 Subject: [PATCH 106/113] Remove files --- index.d.ts | 150 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4997 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 dddbd0c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,150 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Buffer } from 'buffer'; - -/** -* Callback invoked after opening a file. -* -* @param err - error argument -* @param fd - file descriptor -*/ -type Callback = ( err: Error, fd: number ) => void; - -/** -* Interface for opening a file. -*/ -interface Open { - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', 438, onOpen ); - */ - ( path: string | Buffer, flags: string | number, mode: number, clbk: Callback ): void; - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', onOpen ); - */ - ( path: string | Buffer, flags: string | number, clbk: Callback ): void; - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, onOpen ); - */ - ( path: string | Buffer, clbk: Callback ): void; - - /** - * Synchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @returns file descriptor or an error - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * var fd = open.sync( __filename, 'r+' ); - * if ( fd instanceof Error ) { - * throw fd; - * } - * closeSync( fd ); - */ - sync( path: string | Buffer, flags?: string | number, mode?: number ): number | Error; -} - -/** -* Asynchronously opens a file. -* -* @param path - file path -* @param flags - file system flags (default: 'r') -* @param mode - file mode (default: 0o666) -* @param clbk - callback to invoke after opening a file -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* var fd = open.sync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -declare var open: Open; - - -// EXPORTS // - -export = open; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 9e3afbc..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/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var r=t(Object.freeze({__proto__:null,default:{}})),n="r",o=438,c=r.open;function u(e,t,r,u){var i=arguments.length;return 2===i?c(e,n,o,t):3===i?c(e,t,o,r):void c(e,t,r,u)}var i=r.openSync;function s(e,t,r){var c,u;c=arguments.length;try{u=1===c?i(e,n,o):i(e,t,2===c?o:r)}catch(e){return e}return u}e(u,"sync",s);export{u as default,s as sync}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 0d9f33f..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;0nBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAEzB,CAAC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 34bd866..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 939cf40ad5dcc600e0d4b0fdf0f3d66ff57194c2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 01:28:59 +0000 Subject: [PATCH 107/113] 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 | 196 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 55 +- SECURITY.md | 5 - benchmark/benchmark.js | 77 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 65 - docs/types/test.ts | 129 - examples/index.js | 56 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/defaults.json | 4 - lib/index.js | 63 - lib/main.js | 64 - lib/sync.js | 68 - package.json | 58 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 38 - test/test.main.js | 110 - test/test.sync.js | 83 - 47 files changed, 4876 insertions(+), 4324 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/defaults.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/sync.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.sync.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 ba1e508..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-10-01T00:55:22.946Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index a3a4470..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/fs/open) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 7617ad3..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/fs/open) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 d7fc8a0..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: '14 2 * * 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 + + ```
@@ -225,7 +222,7 @@ function onOpen( error, fd ) { ## 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]. @@ -292,11 +289,11 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close +[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close/tree/esm -[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists +[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists/tree/esm -[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file +[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file/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 503cc81..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,77 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var closeSync = require( '@stdlib/fs-close' ).sync; -var pkg = require( './../package.json' ).name; -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return open( __filename, 'r+', done ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function done( error, fd ) { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - if ( error ) { - b.fail( error.message ); - } - next(); - } -}); - -bench( pkg+':sync', function benchmark( b ) { - var fd; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - fd = open.sync( __filename, 'r+' ); - if ( fd instanceof Error ) { - b.fail( fd.message ); - } else { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - } - } - b.toc(); - if ( fd instanceof Error ) { - b.fail( 'something went wrong' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index da1ba5f..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/fs/open" -%% click B href "https://github.com/stdlib-js/fs-open/tree/main" -%% click C href "https://github.com/stdlib-js/fs-open/tree/production" -%% click D href "https://github.com/stdlib-js/fs-open/tree/esm" -%% click E href "https://github.com/stdlib-js/fs-open/tree/deno" -%% click F href "https://github.com/stdlib-js/fs-open/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/fs/open -[production-url]: https://github.com/stdlib-js/fs-open/tree/production -[deno-url]: https://github.com/stdlib-js/fs-open/tree/deno -[deno-readme]: https://github.com/stdlib-js/fs-open/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/fs-open/tree/umd -[umd-readme]: https://github.com/stdlib-js/fs-open/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/fs-open/tree/esm -[esm-readme]: https://github.com/stdlib-js/fs-open/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 3e10601..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import open from '../docs/types/index'; -export = open; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 5358415..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var u=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var i=u(function(b,y){y.exports={flags:"r",mode:438}});var d=u(function(j,f){ -var a=require("fs").open,o=i();function p(r,e,t,s){var n=arguments.length;if(n===2)return a(r,o.flags,o.mode,e);if(n===3)return a(r,e,o.mode,t);a(r,e,t,s)}f.exports=p -});var m=u(function(k,l){ -var c=require("fs").openSync,v=i();function x(r,e,t){var s,n;s=arguments.length;try{s===1?n=c(r,v.flags,v.mode):s===2?n=c(r,e,v.mode):n=c(r,e,t)}catch(g){return g}return n}l.exports=x -});var S=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),q=d(),O=m();S(q,"sync",O);module.exports=q; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 65b6278..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/main.js", "../lib/sync.js", "../lib/index.js"], - "sourcesContent": ["{\n\t\"flags\": \"r\",\n\t\"mode\": 438\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var open = require( '@stdlib/fs-open' );\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nmodule.exports = open;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nmodule.exports = openSync;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var open = require( '@stdlib/fs-open' );\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var openSync = require( '@stdlib/fs-open' ).sync;\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar sync = require( './sync.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,CAAAA,EAAA,SACC,MAAS,IACT,KAAQ,GACT,ICHA,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAK,QAAS,IAAK,EAAE,KACrBC,EAAW,IA0Bf,SAASC,EAAMC,EAAMC,EAAOC,EAAMC,EAAO,CACxC,IAAIC,EAAQ,UAAU,OACtB,GAAKA,IAAU,EACd,OAAOP,EAAIG,EAAMF,EAAS,MAAOA,EAAS,KAAMG,CAAM,EAEvD,GAAKG,IAAU,EACd,OAAOP,EAAIG,EAAMC,EAAOH,EAAS,KAAMI,CAAK,EAE7CL,EAAIG,EAAMC,EAAOC,EAAMC,CAAK,CAC7B,CAKAP,EAAO,QAAUG,IC/DjB,IAAAM,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAO,QAAS,IAAK,EAAE,SACvBC,EAAW,IAsBf,SAASC,EAAUC,EAAMC,EAAOC,EAAO,CACtC,IAAIC,EACAC,EAEJD,EAAQ,UAAU,OAClB,GAAI,CACEA,IAAU,EACdC,EAAKP,EAAMG,EAAMF,EAAS,MAAOA,EAAS,IAAK,EACpCK,IAAU,EACrBC,EAAKP,EAAMG,EAAMC,EAAOH,EAAS,IAAK,EAEtCM,EAAKP,EAAMG,EAAMC,EAAOC,CAAK,CAE/B,OAAUG,EAAM,CACf,OAAOA,CACR,CACA,OAAOD,CACR,CAKAR,EAAO,QAAUG,ICjBjB,IAAIO,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAO,IAKXF,EAAaC,EAAM,OAAQC,CAAK,EAKhC,OAAO,QAAUD", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_main", "__commonJSMin", "exports", "module", "op", "defaults", "open", "path", "flags", "mode", "clbk", "nargs", "require_sync", "__commonJSMin", "exports", "module", "open", "defaults", "openSync", "path", "flags", "mode", "nargs", "fd", "err", "setReadOnly", "main", "sync"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4cbf7ac..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,65 +0,0 @@ - -{{alias}}( path[, flags[, mode]], clbk ) - Asynchronously opens a file. - - Some characters, such as <>:"/\|?*, are reserved under Windows. - Under NTFS, if the path contains a colon, Node.js will open a file system - stream. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - clbk: Function - Callback to invoke upon opening a file. - - Examples - -------- - > function onOpen( error, fd ) { - ... if ( error ) { - ... console.error( error.message ); - ... } else { - ... {{alias:@stdlib/fs/close}}.sync( fd ); - ... } - ... }; - > {{alias}}( './beep/boop.txt', onOpen ); - - -{{alias}}.sync( path[, flags[, mode]] ) - Synchronously opens a file. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - Returns - ------- - fd: Error|integer - File descriptor. - - Examples - -------- - > var fd = {{alias}}.sync( './beep/boop.txt' ); - > if ( !{{alias:@stdlib/assert/is-error}}( fd ) ) { {{alias:@stdlib/fs/close}}.sync( fd ); }; - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 67907a2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,129 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 open = require( './index' ); - -const done = ( error: Error, fd: number ) => { - if ( error || !fd ) { - throw error; - } -}; - - -// TESTS // - -// The function does not have a return value... -{ - open( '/path/to/beepboop', done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a string... -{ - open( 123, done ); // $ExpectError - open( false, done ); // $ExpectError - open( true, done ); // $ExpectError - open( null, done ); // $ExpectError - open( undefined, done ); // $ExpectError - open( [], done ); // $ExpectError - open( {}, done ); // $ExpectError - open( ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a last argument which is not a function with the expected signature... -{ - open( '/path/to/beepboop', 'abc' ); // $ExpectError - open( '/path/to/beepboop', 123 ); // $ExpectError - open( '/path/to/beepboop', false ); // $ExpectError - open( '/path/to/beepboop', true ); // $ExpectError - open( '/path/to/beepboop', null ); // $ExpectError - open( '/path/to/beepboop', undefined ); // $ExpectError - open( '/path/to/beepboop', [] ); // $ExpectError - open( '/path/to/beepboop', {} ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `flags` argument which is not a string or number... -{ - open( '/path/to/beepboop', false, done ); // $ExpectError - open( '/path/to/beepboop', true, done ); // $ExpectError - open( '/path/to/beepboop', null, done ); // $ExpectError - open( '/path/to/beepboop', undefined, done ); // $ExpectError - open( '/path/to/beepboop', [], done ); // $ExpectError - open( '/path/to/beepboop', {}, done ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` argument which is not a number... -{ - open( '/path/to/beepboop', 'r+', 'abc', done ); // $ExpectError - open( '/path/to/beepboop', 'r+', false, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', true, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', null, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', undefined, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', [], done ); // $ExpectError - open( '/path/to/beepboop', 'r+', {}, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - open(); // $ExpectError - open( 'C:\\foo\\bar\\baz' ); // $ExpectError -} - -// Attached to main export is a `sync` method which returns a number or an error... -{ - open.sync( '/path/to/beepboop' ); // $ExpectType number | Error -} - -// The compiler throws an error if the `sync` method is provided a first argument which is not a string... -{ - open.sync( 123 ); // $ExpectError - open.sync( false ); // $ExpectError - open.sync( true ); // $ExpectError - open.sync( null ); // $ExpectError - open.sync( undefined ); // $ExpectError - open.sync( [] ); // $ExpectError - open.sync( {} ); // $ExpectError - open.sync( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a second argument which is not a string or number... -{ - open.sync( '/path/to/beepboop', false ); // $ExpectError - open.sync( '/path/to/beepboop', true ); // $ExpectError - open.sync( '/path/to/beepboop', null ); // $ExpectError - open.sync( '/path/to/beepboop', [] ); // $ExpectError - open.sync( '/path/to/beepboop', {} ); // $ExpectError - open.sync( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a third argument which is not a number... -{ - open.sync( '/path/to/beepboop', 'r+', false ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', true ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', null ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', [] ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', {} ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided an unsupported number of arguments... -{ - open.sync(); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 71359fe..0000000 --- a/examples/index.js +++ /dev/null @@ -1,56 +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. -*/ - -'use strict'; - -var closeSync = require( '@stdlib/fs-close' ).sync; -var isError = require( '@stdlib/assert-is-error' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - -/* Sync */ - -var fd = open.sync( __filename, 'r+' ); -// returns - -console.log( isError( fd ) ); -// => false - -closeSync( fd ); - -fd = open.sync( 'beepboop' ); -// returns - -console.log( isError( fd ) ); -// => true - -/* Async */ - -open( __filename, onOpen ); -open( 'beepboop', onOpen ); - -function onOpen( error, fd ) { - if ( error ) { - if ( error.code === 'ENOENT' ) { - console.error( 'File does not exist.' ); - } else { - throw error; - } - } else { - closeSync( fd ); - } -} 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..9e3afbc --- /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/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var r=t(Object.freeze({__proto__:null,default:{}})),n="r",o=438,c=r.open;function u(e,t,r,u){var i=arguments.length;return 2===i?c(e,n,o,t):3===i?c(e,t,o,r):void c(e,t,r,u)}var i=r.openSync;function s(e,t,r){var c,u;c=arguments.length;try{u=1===c?i(e,n,o):i(e,t,2===c?o:r)}catch(e){return e}return u}e(u,"sync",s);export{u as default,s as sync}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..0d9f33f --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;0nBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAEzB,CAAC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index cb174b7..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "flags": "r", - "mode": 438 -} diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 8edd6de..0000000 --- a/lib/index.js +++ /dev/null @@ -1,63 +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. -*/ - -'use strict'; - -/** -* Open a file. -* -* @module @stdlib/fs-open -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var openSync = require( '@stdlib/fs-open' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var sync = require( './sync.js' ); - - -// MAIN // - -setReadOnly( main, 'sync', sync ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index feb5171..0000000 --- a/lib/main.js +++ /dev/null @@ -1,64 +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. -*/ - -'use strict'; - -// MODULES // - -var op = require( 'fs' ).open; -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Asynchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @param {Function} clbk - callback to invoke after opening a file -* @returns {void} -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -*/ -function open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare - var nargs = arguments.length; - if ( nargs === 2 ) { - return op( path, defaults.flags, defaults.mode, flags ); - } - if ( nargs === 3 ) { - return op( path, flags, defaults.mode, mode ); - } - op( path, flags, mode, clbk ); -} - - -// EXPORTS // - -module.exports = open; diff --git a/lib/sync.js b/lib/sync.js deleted file mode 100644 index d8d2e00..0000000 --- a/lib/sync.js +++ /dev/null @@ -1,68 +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. -*/ - -'use strict'; - -// MODULES // - -var open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Synchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @returns {(integer|Error)} file descriptor or an error -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -function openSync( path, flags, mode ) { - var nargs; - var fd; - - nargs = arguments.length; - try { - if ( nargs === 1 ) { - fd = open( path, defaults.flags, defaults.mode ); - } else if ( nargs === 2 ) { - fd = open( path, flags, defaults.mode ); - } else { - fd = open( path, flags, mode ); - } - } catch ( err ) { - return err; - } - return fd; -} - - -// EXPORTS // - -module.exports = openSync; diff --git a/package.json b/package.json index e20fa42..c2272c8 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Open a file.", "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/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.2.2", - "@stdlib/assert-is-error": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/fs-close": "^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", "stdfs", @@ -82,4 +30,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..34bd866 --- /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 3c47135..0000000 --- a/test/test.js +++ /dev/null @@ -1,38 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is a function to open a file synchronously', function test( t ) { - t.equal( typeof open.sync, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 33b938f..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,110 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/main.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - open( __filename, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - open( __filename, 'r+', onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - open( __filename, 'r+', 438, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - open( 'beepboopbapbop', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', 438, onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); diff --git a/test/test.sync.js b/test/test.sync.js deleted file mode 100644 index 56d7b23..0000000 --- a/test/test.sync.js +++ /dev/null @@ -1,83 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/sync.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - var fd = open( __filename ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - var fd = open( __filename, 'r+' ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - var fd = open( __filename, 'r+', 438 ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - var fd = open( 'beepboopbapbop' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+', 438 ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); From 226390b52701e7274f7539e925910883547ccea4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 01:02:27 +0000 Subject: [PATCH 108/113] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index acacb8b..e20fa42 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.2.2", @@ -81,4 +82,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 18c6eea7762c9afac48a49db58fc984febc8d040 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 01:28:16 +0000 Subject: [PATCH 109/113] Remove files --- index.d.ts | 150 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4997 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 dddbd0c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,150 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Buffer } from 'buffer'; - -/** -* Callback invoked after opening a file. -* -* @param err - error argument -* @param fd - file descriptor -*/ -type Callback = ( err: Error, fd: number ) => void; - -/** -* Interface for opening a file. -*/ -interface Open { - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', 438, onOpen ); - */ - ( path: string | Buffer, flags: string | number, mode: number, clbk: Callback ): void; - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', onOpen ); - */ - ( path: string | Buffer, flags: string | number, clbk: Callback ): void; - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, onOpen ); - */ - ( path: string | Buffer, clbk: Callback ): void; - - /** - * Synchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @returns file descriptor or an error - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * var fd = open.sync( __filename, 'r+' ); - * if ( fd instanceof Error ) { - * throw fd; - * } - * closeSync( fd ); - */ - sync( path: string | Buffer, flags?: string | number, mode?: number ): number | Error; -} - -/** -* Asynchronously opens a file. -* -* @param path - file path -* @param flags - file system flags (default: 'r') -* @param mode - file mode (default: 0o666) -* @param clbk - callback to invoke after opening a file -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* var fd = open.sync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -declare var open: Open; - - -// EXPORTS // - -export = open; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 9e3afbc..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/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var r=t(Object.freeze({__proto__:null,default:{}})),n="r",o=438,c=r.open;function u(e,t,r,u){var i=arguments.length;return 2===i?c(e,n,o,t):3===i?c(e,t,o,r):void c(e,t,r,u)}var i=r.openSync;function s(e,t,r){var c,u;c=arguments.length;try{u=1===c?i(e,n,o):i(e,t,2===c?o:r)}catch(e){return e}return u}e(u,"sync",s);export{u as default,s as sync}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 0d9f33f..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;0nBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAEzB,CAAC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 34bd866..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 24ac20eab1e16d8974747f93d52e08ed484a5a3d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 01:28:28 +0000 Subject: [PATCH 110/113] 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 | 196 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 55 +- SECURITY.md | 5 - benchmark/benchmark.js | 77 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 65 - docs/types/test.ts | 129 - examples/index.js | 56 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/defaults.json | 4 - lib/index.js | 63 - lib/main.js | 64 - lib/sync.js | 68 - package.json | 58 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 38 - test/test.main.js | 110 - test/test.sync.js | 83 - 47 files changed, 4876 insertions(+), 4324 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/defaults.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/sync.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.sync.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 6d1d05f..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-11-01T00:56:34.298Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index a3a4470..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/fs/open) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 7617ad3..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/fs/open) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 d7fc8a0..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: '14 2 * * 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 + + ```
@@ -225,7 +222,7 @@ function onOpen( error, fd ) { ## 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]. @@ -292,11 +289,11 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close +[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close/tree/esm -[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists +[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists/tree/esm -[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file +[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file/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 503cc81..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,77 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var closeSync = require( '@stdlib/fs-close' ).sync; -var pkg = require( './../package.json' ).name; -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return open( __filename, 'r+', done ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function done( error, fd ) { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - if ( error ) { - b.fail( error.message ); - } - next(); - } -}); - -bench( pkg+':sync', function benchmark( b ) { - var fd; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - fd = open.sync( __filename, 'r+' ); - if ( fd instanceof Error ) { - b.fail( fd.message ); - } else { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - } - } - b.toc(); - if ( fd instanceof Error ) { - b.fail( 'something went wrong' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index da1ba5f..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/fs/open" -%% click B href "https://github.com/stdlib-js/fs-open/tree/main" -%% click C href "https://github.com/stdlib-js/fs-open/tree/production" -%% click D href "https://github.com/stdlib-js/fs-open/tree/esm" -%% click E href "https://github.com/stdlib-js/fs-open/tree/deno" -%% click F href "https://github.com/stdlib-js/fs-open/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/fs/open -[production-url]: https://github.com/stdlib-js/fs-open/tree/production -[deno-url]: https://github.com/stdlib-js/fs-open/tree/deno -[deno-readme]: https://github.com/stdlib-js/fs-open/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/fs-open/tree/umd -[umd-readme]: https://github.com/stdlib-js/fs-open/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/fs-open/tree/esm -[esm-readme]: https://github.com/stdlib-js/fs-open/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 3e10601..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import open from '../docs/types/index'; -export = open; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 5358415..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var u=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var i=u(function(b,y){y.exports={flags:"r",mode:438}});var d=u(function(j,f){ -var a=require("fs").open,o=i();function p(r,e,t,s){var n=arguments.length;if(n===2)return a(r,o.flags,o.mode,e);if(n===3)return a(r,e,o.mode,t);a(r,e,t,s)}f.exports=p -});var m=u(function(k,l){ -var c=require("fs").openSync,v=i();function x(r,e,t){var s,n;s=arguments.length;try{s===1?n=c(r,v.flags,v.mode):s===2?n=c(r,e,v.mode):n=c(r,e,t)}catch(g){return g}return n}l.exports=x -});var S=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),q=d(),O=m();S(q,"sync",O);module.exports=q; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 65b6278..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/main.js", "../lib/sync.js", "../lib/index.js"], - "sourcesContent": ["{\n\t\"flags\": \"r\",\n\t\"mode\": 438\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var open = require( '@stdlib/fs-open' );\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nmodule.exports = open;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nmodule.exports = openSync;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var open = require( '@stdlib/fs-open' );\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var openSync = require( '@stdlib/fs-open' ).sync;\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar sync = require( './sync.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,CAAAA,EAAA,SACC,MAAS,IACT,KAAQ,GACT,ICHA,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAK,QAAS,IAAK,EAAE,KACrBC,EAAW,IA0Bf,SAASC,EAAMC,EAAMC,EAAOC,EAAMC,EAAO,CACxC,IAAIC,EAAQ,UAAU,OACtB,GAAKA,IAAU,EACd,OAAOP,EAAIG,EAAMF,EAAS,MAAOA,EAAS,KAAMG,CAAM,EAEvD,GAAKG,IAAU,EACd,OAAOP,EAAIG,EAAMC,EAAOH,EAAS,KAAMI,CAAK,EAE7CL,EAAIG,EAAMC,EAAOC,EAAMC,CAAK,CAC7B,CAKAP,EAAO,QAAUG,IC/DjB,IAAAM,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAO,QAAS,IAAK,EAAE,SACvBC,EAAW,IAsBf,SAASC,EAAUC,EAAMC,EAAOC,EAAO,CACtC,IAAIC,EACAC,EAEJD,EAAQ,UAAU,OAClB,GAAI,CACEA,IAAU,EACdC,EAAKP,EAAMG,EAAMF,EAAS,MAAOA,EAAS,IAAK,EACpCK,IAAU,EACrBC,EAAKP,EAAMG,EAAMC,EAAOH,EAAS,IAAK,EAEtCM,EAAKP,EAAMG,EAAMC,EAAOC,CAAK,CAE/B,OAAUG,EAAM,CACf,OAAOA,CACR,CACA,OAAOD,CACR,CAKAR,EAAO,QAAUG,ICjBjB,IAAIO,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAO,IAKXF,EAAaC,EAAM,OAAQC,CAAK,EAKhC,OAAO,QAAUD", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_main", "__commonJSMin", "exports", "module", "op", "defaults", "open", "path", "flags", "mode", "clbk", "nargs", "require_sync", "__commonJSMin", "exports", "module", "open", "defaults", "openSync", "path", "flags", "mode", "nargs", "fd", "err", "setReadOnly", "main", "sync"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4cbf7ac..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,65 +0,0 @@ - -{{alias}}( path[, flags[, mode]], clbk ) - Asynchronously opens a file. - - Some characters, such as <>:"/\|?*, are reserved under Windows. - Under NTFS, if the path contains a colon, Node.js will open a file system - stream. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - clbk: Function - Callback to invoke upon opening a file. - - Examples - -------- - > function onOpen( error, fd ) { - ... if ( error ) { - ... console.error( error.message ); - ... } else { - ... {{alias:@stdlib/fs/close}}.sync( fd ); - ... } - ... }; - > {{alias}}( './beep/boop.txt', onOpen ); - - -{{alias}}.sync( path[, flags[, mode]] ) - Synchronously opens a file. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - Returns - ------- - fd: Error|integer - File descriptor. - - Examples - -------- - > var fd = {{alias}}.sync( './beep/boop.txt' ); - > if ( !{{alias:@stdlib/assert/is-error}}( fd ) ) { {{alias:@stdlib/fs/close}}.sync( fd ); }; - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 67907a2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,129 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 open = require( './index' ); - -const done = ( error: Error, fd: number ) => { - if ( error || !fd ) { - throw error; - } -}; - - -// TESTS // - -// The function does not have a return value... -{ - open( '/path/to/beepboop', done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a string... -{ - open( 123, done ); // $ExpectError - open( false, done ); // $ExpectError - open( true, done ); // $ExpectError - open( null, done ); // $ExpectError - open( undefined, done ); // $ExpectError - open( [], done ); // $ExpectError - open( {}, done ); // $ExpectError - open( ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a last argument which is not a function with the expected signature... -{ - open( '/path/to/beepboop', 'abc' ); // $ExpectError - open( '/path/to/beepboop', 123 ); // $ExpectError - open( '/path/to/beepboop', false ); // $ExpectError - open( '/path/to/beepboop', true ); // $ExpectError - open( '/path/to/beepboop', null ); // $ExpectError - open( '/path/to/beepboop', undefined ); // $ExpectError - open( '/path/to/beepboop', [] ); // $ExpectError - open( '/path/to/beepboop', {} ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `flags` argument which is not a string or number... -{ - open( '/path/to/beepboop', false, done ); // $ExpectError - open( '/path/to/beepboop', true, done ); // $ExpectError - open( '/path/to/beepboop', null, done ); // $ExpectError - open( '/path/to/beepboop', undefined, done ); // $ExpectError - open( '/path/to/beepboop', [], done ); // $ExpectError - open( '/path/to/beepboop', {}, done ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` argument which is not a number... -{ - open( '/path/to/beepboop', 'r+', 'abc', done ); // $ExpectError - open( '/path/to/beepboop', 'r+', false, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', true, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', null, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', undefined, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', [], done ); // $ExpectError - open( '/path/to/beepboop', 'r+', {}, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - open(); // $ExpectError - open( 'C:\\foo\\bar\\baz' ); // $ExpectError -} - -// Attached to main export is a `sync` method which returns a number or an error... -{ - open.sync( '/path/to/beepboop' ); // $ExpectType number | Error -} - -// The compiler throws an error if the `sync` method is provided a first argument which is not a string... -{ - open.sync( 123 ); // $ExpectError - open.sync( false ); // $ExpectError - open.sync( true ); // $ExpectError - open.sync( null ); // $ExpectError - open.sync( undefined ); // $ExpectError - open.sync( [] ); // $ExpectError - open.sync( {} ); // $ExpectError - open.sync( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a second argument which is not a string or number... -{ - open.sync( '/path/to/beepboop', false ); // $ExpectError - open.sync( '/path/to/beepboop', true ); // $ExpectError - open.sync( '/path/to/beepboop', null ); // $ExpectError - open.sync( '/path/to/beepboop', [] ); // $ExpectError - open.sync( '/path/to/beepboop', {} ); // $ExpectError - open.sync( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a third argument which is not a number... -{ - open.sync( '/path/to/beepboop', 'r+', false ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', true ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', null ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', [] ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', {} ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided an unsupported number of arguments... -{ - open.sync(); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 71359fe..0000000 --- a/examples/index.js +++ /dev/null @@ -1,56 +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. -*/ - -'use strict'; - -var closeSync = require( '@stdlib/fs-close' ).sync; -var isError = require( '@stdlib/assert-is-error' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - -/* Sync */ - -var fd = open.sync( __filename, 'r+' ); -// returns - -console.log( isError( fd ) ); -// => false - -closeSync( fd ); - -fd = open.sync( 'beepboop' ); -// returns - -console.log( isError( fd ) ); -// => true - -/* Async */ - -open( __filename, onOpen ); -open( 'beepboop', onOpen ); - -function onOpen( error, fd ) { - if ( error ) { - if ( error.code === 'ENOENT' ) { - console.error( 'File does not exist.' ); - } else { - throw error; - } - } else { - closeSync( fd ); - } -} 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..9e3afbc --- /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/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var r=t(Object.freeze({__proto__:null,default:{}})),n="r",o=438,c=r.open;function u(e,t,r,u){var i=arguments.length;return 2===i?c(e,n,o,t):3===i?c(e,t,o,r):void c(e,t,r,u)}var i=r.openSync;function s(e,t,r){var c,u;c=arguments.length;try{u=1===c?i(e,n,o):i(e,t,2===c?o:r)}catch(e){return e}return u}e(u,"sync",s);export{u as default,s as sync}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..0d9f33f --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;0nBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAEzB,CAAC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index cb174b7..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "flags": "r", - "mode": 438 -} diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 8edd6de..0000000 --- a/lib/index.js +++ /dev/null @@ -1,63 +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. -*/ - -'use strict'; - -/** -* Open a file. -* -* @module @stdlib/fs-open -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var openSync = require( '@stdlib/fs-open' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var sync = require( './sync.js' ); - - -// MAIN // - -setReadOnly( main, 'sync', sync ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index feb5171..0000000 --- a/lib/main.js +++ /dev/null @@ -1,64 +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. -*/ - -'use strict'; - -// MODULES // - -var op = require( 'fs' ).open; -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Asynchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @param {Function} clbk - callback to invoke after opening a file -* @returns {void} -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -*/ -function open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare - var nargs = arguments.length; - if ( nargs === 2 ) { - return op( path, defaults.flags, defaults.mode, flags ); - } - if ( nargs === 3 ) { - return op( path, flags, defaults.mode, mode ); - } - op( path, flags, mode, clbk ); -} - - -// EXPORTS // - -module.exports = open; diff --git a/lib/sync.js b/lib/sync.js deleted file mode 100644 index d8d2e00..0000000 --- a/lib/sync.js +++ /dev/null @@ -1,68 +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. -*/ - -'use strict'; - -// MODULES // - -var open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Synchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @returns {(integer|Error)} file descriptor or an error -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -function openSync( path, flags, mode ) { - var nargs; - var fd; - - nargs = arguments.length; - try { - if ( nargs === 1 ) { - fd = open( path, defaults.flags, defaults.mode ); - } else if ( nargs === 2 ) { - fd = open( path, flags, defaults.mode ); - } else { - fd = open( path, flags, mode ); - } - } catch ( err ) { - return err; - } - return fd; -} - - -// EXPORTS // - -module.exports = openSync; diff --git a/package.json b/package.json index e20fa42..c2272c8 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Open a file.", "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/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.2.2", - "@stdlib/assert-is-error": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/fs-close": "^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", "stdfs", @@ -82,4 +30,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..34bd866 --- /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 3c47135..0000000 --- a/test/test.js +++ /dev/null @@ -1,38 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is a function to open a file synchronously', function test( t ) { - t.equal( typeof open.sync, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 33b938f..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,110 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/main.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - open( __filename, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - open( __filename, 'r+', onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - open( __filename, 'r+', 438, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - open( 'beepboopbapbop', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', 438, onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); diff --git a/test/test.sync.js b/test/test.sync.js deleted file mode 100644 index 56d7b23..0000000 --- a/test/test.sync.js +++ /dev/null @@ -1,83 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/sync.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - var fd = open( __filename ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - var fd = open( __filename, 'r+' ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - var fd = open( __filename, 'r+', 438 ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - var fd = open( 'beepboopbapbop' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+', 438 ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); From 2733b6d2f3e0e9b78d96e1e770109719364f6f8c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 01:10:15 +0000 Subject: [PATCH 111/113] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index acacb8b..e20fa42 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/assert-is-browser": "^0.2.2", @@ -81,4 +82,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 9b0f3efad89d1913539b8d9812e0b6825e794648 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 01:36:21 +0000 Subject: [PATCH 112/113] Remove files --- index.d.ts | 150 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4997 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 dddbd0c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,150 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Buffer } from 'buffer'; - -/** -* Callback invoked after opening a file. -* -* @param err - error argument -* @param fd - file descriptor -*/ -type Callback = ( err: Error, fd: number ) => void; - -/** -* Interface for opening a file. -*/ -interface Open { - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', 438, onOpen ); - */ - ( path: string | Buffer, flags: string | number, mode: number, clbk: Callback ): void; - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, 'r+', onOpen ); - */ - ( path: string | Buffer, flags: string | number, clbk: Callback ): void; - - /** - * Asynchronously opens a file. - * - * @param path - file path - * @param clbk - callback to invoke after opening a file - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * function onOpen( error, fd ) { - * if ( error ) { - * throw error; - * } - * closeSync( fd ); - * } - * open( __filename, onOpen ); - */ - ( path: string | Buffer, clbk: Callback ): void; - - /** - * Synchronously opens a file. - * - * @param path - file path - * @param flags - file system flags (default: 'r') - * @param mode - file mode (default: 0o666) - * @returns file descriptor or an error - * - * @example - * var closeSync = require( '@stdlib/fs-close' ).sync; - * - * var fd = open.sync( __filename, 'r+' ); - * if ( fd instanceof Error ) { - * throw fd; - * } - * closeSync( fd ); - */ - sync( path: string | Buffer, flags?: string | number, mode?: number ): number | Error; -} - -/** -* Asynchronously opens a file. -* -* @param path - file path -* @param flags - file system flags (default: 'r') -* @param mode - file mode (default: 0o666) -* @param clbk - callback to invoke after opening a file -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* var fd = open.sync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -declare var open: Open; - - -// EXPORTS // - -export = open; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 9e3afbc..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/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var r=t(Object.freeze({__proto__:null,default:{}})),n="r",o=438,c=r.open;function u(e,t,r,u){var i=arguments.length;return 2===i?c(e,n,o,t):3===i?c(e,t,o,r):void c(e,t,r,u)}var i=r.openSync;function s(e,t,r){var c,u;c=arguments.length;try{u=1===c?i(e,n,o):i(e,t,2===c?o:r)}catch(e){return e}return u}e(u,"sync",s);export{u as default,s as sync}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 0d9f33f..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;0nBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAEzB,CAAC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 34bd866..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 8722f96809731ce80dd60b669b69cab6302c729c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 01:36:55 +0000 Subject: [PATCH 113/113] 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 | 196 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 55 +- SECURITY.md | 5 - benchmark/benchmark.js | 77 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 65 - docs/types/test.ts | 129 - examples/index.js | 56 - docs/types/index.d.ts => index.d.ts | 0 index.mjs | 4 + index.mjs.map | 1 + lib/defaults.json | 4 - lib/index.js | 63 - lib/main.js | 64 - lib/sync.js | 68 - package.json | 58 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 38 - test/test.main.js | 110 - test/test.sync.js | 83 - 48 files changed, 4876 insertions(+), 4429 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/defaults.json delete mode 100644 lib/index.js delete mode 100644 lib/main.js delete mode 100644 lib/sync.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js delete mode 100644 test/test.sync.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 0f18b01..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-12-01T01:02:58.738Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index a3a4470..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/fs/open) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be 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 7617ad3..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/fs/open) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be 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 d7fc8a0..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: '14 2 * * 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 + + ```
@@ -225,7 +222,7 @@ function onOpen( error, fd ) { ## 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]. @@ -292,11 +289,11 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. -[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close +[@stdlib/fs/close]: https://github.com/stdlib-js/fs-close/tree/esm -[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists +[@stdlib/fs/exists]: https://github.com/stdlib-js/fs-exists/tree/esm -[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file +[@stdlib/fs/read-file]: https://github.com/stdlib-js/fs-read-file/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 503cc81..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,77 +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. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var closeSync = require( '@stdlib/fs-close' ).sync; -var pkg = require( './../package.json' ).name; -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var i; - - i = 0; - b.tic(); - - return next(); - - function next() { - i += 1; - if ( i <= b.iterations ) { - return open( __filename, 'r+', done ); - } - b.toc(); - b.pass( 'benchmark finished' ); - b.end(); - } - - function done( error, fd ) { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - if ( error ) { - b.fail( error.message ); - } - next(); - } -}); - -bench( pkg+':sync', function benchmark( b ) { - var fd; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - fd = open.sync( __filename, 'r+' ); - if ( fd instanceof Error ) { - b.fail( fd.message ); - } else { - closeSync( fd ); // necessary in order to avoid leaking file descriptors - } - } - b.toc(); - if ( fd instanceof Error ) { - b.fail( 'something went wrong' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index da1ba5f..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/fs/open" -%% click B href "https://github.com/stdlib-js/fs-open/tree/main" -%% click C href "https://github.com/stdlib-js/fs-open/tree/production" -%% click D href "https://github.com/stdlib-js/fs-open/tree/esm" -%% click E href "https://github.com/stdlib-js/fs-open/tree/deno" -%% click F href "https://github.com/stdlib-js/fs-open/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/fs/open -[production-url]: https://github.com/stdlib-js/fs-open/tree/production -[deno-url]: https://github.com/stdlib-js/fs-open/tree/deno -[deno-readme]: https://github.com/stdlib-js/fs-open/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/fs-open/tree/umd -[umd-readme]: https://github.com/stdlib-js/fs-open/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/fs-open/tree/esm -[esm-readme]: https://github.com/stdlib-js/fs-open/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 3e10601..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import open from '../docs/types/index'; -export = open; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 5358415..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var u=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var i=u(function(b,y){y.exports={flags:"r",mode:438}});var d=u(function(j,f){ -var a=require("fs").open,o=i();function p(r,e,t,s){var n=arguments.length;if(n===2)return a(r,o.flags,o.mode,e);if(n===3)return a(r,e,o.mode,t);a(r,e,t,s)}f.exports=p -});var m=u(function(k,l){ -var c=require("fs").openSync,v=i();function x(r,e,t){var s,n;s=arguments.length;try{s===1?n=c(r,v.flags,v.mode):s===2?n=c(r,e,v.mode):n=c(r,e,t)}catch(g){return g}return n}l.exports=x -});var S=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),q=d(),O=m();S(q,"sync",O);module.exports=q; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 65b6278..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/defaults.json", "../lib/main.js", "../lib/sync.js", "../lib/index.js"], - "sourcesContent": ["{\n\t\"flags\": \"r\",\n\t\"mode\": 438\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var open = require( '@stdlib/fs-open' );\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nmodule.exports = open;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nvar defaults = require( './defaults.json' );\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nmodule.exports = openSync;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var open = require( '@stdlib/fs-open' );\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* var closeSync = require( '@stdlib/fs-close' ).sync;\n* var openSync = require( '@stdlib/fs-open' ).sync;\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar sync = require( './sync.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,CAAAA,EAAA,SACC,MAAS,IACT,KAAQ,GACT,ICHA,IAAAC,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAK,QAAS,IAAK,EAAE,KACrBC,EAAW,IA0Bf,SAASC,EAAMC,EAAMC,EAAOC,EAAMC,EAAO,CACxC,IAAIC,EAAQ,UAAU,OACtB,GAAKA,IAAU,EACd,OAAOP,EAAIG,EAAMF,EAAS,MAAOA,EAAS,KAAMG,CAAM,EAEvD,GAAKG,IAAU,EACd,OAAOP,EAAIG,EAAMC,EAAOH,EAAS,KAAMI,CAAK,EAE7CL,EAAIG,EAAMC,EAAOC,EAAMC,CAAK,CAC7B,CAKAP,EAAO,QAAUG,IC/DjB,IAAAM,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAO,QAAS,IAAK,EAAE,SACvBC,EAAW,IAsBf,SAASC,EAAUC,EAAMC,EAAOC,EAAO,CACtC,IAAIC,EACAC,EAEJD,EAAQ,UAAU,OAClB,GAAI,CACEA,IAAU,EACdC,EAAKP,EAAMG,EAAMF,EAAS,MAAOA,EAAS,IAAK,EACpCK,IAAU,EACrBC,EAAKP,EAAMG,EAAMC,EAAOH,EAAS,IAAK,EAEtCM,EAAKP,EAAMG,EAAMC,EAAOC,CAAK,CAE/B,OAAUG,EAAM,CACf,OAAOA,CACR,CACA,OAAOD,CACR,CAKAR,EAAO,QAAUG,ICjBjB,IAAIO,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAO,IAKXF,EAAaC,EAAM,OAAQC,CAAK,EAKhC,OAAO,QAAUD", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_main", "__commonJSMin", "exports", "module", "op", "defaults", "open", "path", "flags", "mode", "clbk", "nargs", "require_sync", "__commonJSMin", "exports", "module", "open", "defaults", "openSync", "path", "flags", "mode", "nargs", "fd", "err", "setReadOnly", "main", "sync"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 4cbf7ac..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,65 +0,0 @@ - -{{alias}}( path[, flags[, mode]], clbk ) - Asynchronously opens a file. - - Some characters, such as <>:"/\|?*, are reserved under Windows. - Under NTFS, if the path contains a colon, Node.js will open a file system - stream. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - clbk: Function - Callback to invoke upon opening a file. - - Examples - -------- - > function onOpen( error, fd ) { - ... if ( error ) { - ... console.error( error.message ); - ... } else { - ... {{alias:@stdlib/fs/close}}.sync( fd ); - ... } - ... }; - > {{alias}}( './beep/boop.txt', onOpen ); - - -{{alias}}.sync( path[, flags[, mode]] ) - Synchronously opens a file. - - Parameters - ---------- - path: string|Buffer - Filename. - - flags: string|number (optional) - File system flags. Default: 'r'. - - mode: integer (optional) - File mode (permission and sticky bits). This sets the file mode, but - only if the file was created. On Windows, only the write permission can - be manipulated. Default: 0o666. - - Returns - ------- - fd: Error|integer - File descriptor. - - Examples - -------- - > var fd = {{alias}}.sync( './beep/boop.txt' ); - > if ( !{{alias:@stdlib/assert/is-error}}( fd ) ) { {{alias:@stdlib/fs/close}}.sync( fd ); }; - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 67907a2..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,129 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2020 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 open = require( './index' ); - -const done = ( error: Error, fd: number ) => { - if ( error || !fd ) { - throw error; - } -}; - - -// TESTS // - -// The function does not have a return value... -{ - open( '/path/to/beepboop', done ); // $ExpectType void -} - -// The compiler throws an error if the function is provided a first argument which is not a string... -{ - open( 123, done ); // $ExpectError - open( false, done ); // $ExpectError - open( true, done ); // $ExpectError - open( null, done ); // $ExpectError - open( undefined, done ); // $ExpectError - open( [], done ); // $ExpectError - open( {}, done ); // $ExpectError - open( ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a last argument which is not a function with the expected signature... -{ - open( '/path/to/beepboop', 'abc' ); // $ExpectError - open( '/path/to/beepboop', 123 ); // $ExpectError - open( '/path/to/beepboop', false ); // $ExpectError - open( '/path/to/beepboop', true ); // $ExpectError - open( '/path/to/beepboop', null ); // $ExpectError - open( '/path/to/beepboop', undefined ); // $ExpectError - open( '/path/to/beepboop', [] ); // $ExpectError - open( '/path/to/beepboop', {} ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `flags` argument which is not a string or number... -{ - open( '/path/to/beepboop', false, done ); // $ExpectError - open( '/path/to/beepboop', true, done ); // $ExpectError - open( '/path/to/beepboop', null, done ); // $ExpectError - open( '/path/to/beepboop', undefined, done ); // $ExpectError - open( '/path/to/beepboop', [], done ); // $ExpectError - open( '/path/to/beepboop', {}, done ); // $ExpectError - open( '/path/to/beepboop', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided a `mode` argument which is not a number... -{ - open( '/path/to/beepboop', 'r+', 'abc', done ); // $ExpectError - open( '/path/to/beepboop', 'r+', false, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', true, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', null, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', undefined, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', [], done ); // $ExpectError - open( '/path/to/beepboop', 'r+', {}, done ); // $ExpectError - open( '/path/to/beepboop', 'r+', ( x: number ): number => x, done ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - open(); // $ExpectError - open( 'C:\\foo\\bar\\baz' ); // $ExpectError -} - -// Attached to main export is a `sync` method which returns a number or an error... -{ - open.sync( '/path/to/beepboop' ); // $ExpectType number | Error -} - -// The compiler throws an error if the `sync` method is provided a first argument which is not a string... -{ - open.sync( 123 ); // $ExpectError - open.sync( false ); // $ExpectError - open.sync( true ); // $ExpectError - open.sync( null ); // $ExpectError - open.sync( undefined ); // $ExpectError - open.sync( [] ); // $ExpectError - open.sync( {} ); // $ExpectError - open.sync( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a second argument which is not a string or number... -{ - open.sync( '/path/to/beepboop', false ); // $ExpectError - open.sync( '/path/to/beepboop', true ); // $ExpectError - open.sync( '/path/to/beepboop', null ); // $ExpectError - open.sync( '/path/to/beepboop', [] ); // $ExpectError - open.sync( '/path/to/beepboop', {} ); // $ExpectError - open.sync( '/path/to/beepboop', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided a third argument which is not a number... -{ - open.sync( '/path/to/beepboop', 'r+', false ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', true ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', null ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', [] ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', {} ); // $ExpectError - open.sync( '/path/to/beepboop', 'r+', ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the `sync` method is provided an unsupported number of arguments... -{ - open.sync(); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 71359fe..0000000 --- a/examples/index.js +++ /dev/null @@ -1,56 +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. -*/ - -'use strict'; - -var closeSync = require( '@stdlib/fs-close' ).sync; -var isError = require( '@stdlib/assert-is-error' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - -/* Sync */ - -var fd = open.sync( __filename, 'r+' ); -// returns - -console.log( isError( fd ) ); -// => false - -closeSync( fd ); - -fd = open.sync( 'beepboop' ); -// returns - -console.log( isError( fd ) ); -// => true - -/* Async */ - -open( __filename, onOpen ); -open( 'beepboop', onOpen ); - -function onOpen( error, fd ) { - if ( error ) { - if ( error.code === 'ENOENT' ) { - console.error( 'File does not exist.' ); - } else { - throw error; - } - } else { - closeSync( fd ); - } -} 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..9e3afbc --- /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/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function t(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var r=t(Object.freeze({__proto__:null,default:{}})),n="r",o=438,c=r.open;function u(e,t,r,u){var i=arguments.length;return 2===i?c(e,n,o,t):3===i?c(e,t,o,r):void c(e,t,r,u)}var i=r.openSync;function s(e,t,r){var c,u;c=arguments.length;try{u=1===c?i(e,n,o):i(e,t,2===c?o:r)}catch(e){return e}return u}e(u,"sync",s);export{u as default,s as sync}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..0d9f33f --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js","../lib/sync.js","../lib/index.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar op = require( 'fs' ).open;\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Asynchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @param {Function} clbk - callback to invoke after opening a file\n* @returns {void}\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*/\nfunction open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare\n\tvar nargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\treturn op( path, defaults.flags, defaults.mode, flags );\n\t}\n\tif ( nargs === 3 ) {\n\t\treturn op( path, flags, defaults.mode, mode );\n\t}\n\top( path, flags, mode, clbk );\n}\n\n\n// EXPORTS //\n\nexport default open;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare\nimport defaults from './defaults.json';\n\n\n// MAIN //\n\n/**\n* Synchronously opens a file.\n*\n* @param {(string|Buffer)} path - file path\n* @param {(string|number)} [flags='r'] - file system flags\n* @param {integer} [mode=0o666] - file mode\n* @returns {(integer|Error)} file descriptor or an error\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\nfunction openSync( path, flags, mode ) {\n\tvar nargs;\n\tvar fd;\n\n\tnargs = arguments.length;\n\ttry {\n\t\tif ( nargs === 1 ) {\n\t\t\tfd = open( path, defaults.flags, defaults.mode );\n\t\t} else if ( nargs === 2 ) {\n\t\t\tfd = open( path, flags, defaults.mode );\n\t\t} else {\n\t\t\tfd = open( path, flags, mode );\n\t\t}\n\t} catch ( err ) {\n\t\treturn err;\n\t}\n\treturn fd;\n}\n\n\n// EXPORTS //\n\nexport default openSync;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2019 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* Open a file.\n*\n* @module @stdlib/fs-open\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import open from '@stdlib/fs-open';\n*\n* function onOpen( error, fd ) {\n* if ( error ) {\n* throw error;\n* }\n* closeSync( fd );\n* }\n* open( __filename, onOpen );\n*\n* @example\n* import { sync as closeSync } from '@stdlib/fs-close';\n* import { sync as openSync } from '@stdlib/fs-open';\n*\n* var fd = openSync( __filename );\n* if ( fd instanceof Error ) {\n* throw fd;\n* }\n* closeSync( fd );\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport sync from './sync.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'sync', sync );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["op","require$$0","open","path","flags","mode","clbk","nargs","arguments","length","defaults","openSync","fd","err","setReadOnly","main","sync"],"mappings":";;0nBAsBIA,EAAKC,EAAgBC,KA2BzB,SAASA,EAAMC,EAAMC,EAAOC,EAAMC,GACjC,IAAIC,EAAQC,UAAUC,OACtB,OAAe,IAAVF,EACGP,EAAIG,EAAMO,EAAgBA,EAAeN,GAElC,IAAVG,EACGP,EAAIG,EAAMC,EAAOM,EAAeL,QAExCL,EAAIG,EAAMC,EAAOC,EAAMC,EACxB,CCpCA,IAAIJ,EAAOD,EAAgBU,SAuB3B,SAASA,EAAUR,EAAMC,EAAOC,GAC/B,IAAIE,EACAK,EAEJL,EAAQC,UAAUC,OAClB,IAEEG,EADc,IAAVL,EACCL,EAAMC,EAAMO,EAAgBA,GAE5BR,EAAMC,EAAMC,EADI,IAAVG,EACaG,EAEAL,EAEzB,CAAC,MAAQQ,GACT,OAAOA,CACP,CACD,OAAOD,CACR,CCLAE,EAAAC,EAAA,OAAAC"} \ No newline at end of file diff --git a/lib/defaults.json b/lib/defaults.json deleted file mode 100644 index cb174b7..0000000 --- a/lib/defaults.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "flags": "r", - "mode": 438 -} diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 8edd6de..0000000 --- a/lib/index.js +++ /dev/null @@ -1,63 +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. -*/ - -'use strict'; - -/** -* Open a file. -* -* @module @stdlib/fs-open -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var openSync = require( '@stdlib/fs-open' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var sync = require( './sync.js' ); - - -// MAIN // - -setReadOnly( main, 'sync', sync ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index feb5171..0000000 --- a/lib/main.js +++ /dev/null @@ -1,64 +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. -*/ - -'use strict'; - -// MODULES // - -var op = require( 'fs' ).open; -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Asynchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @param {Function} clbk - callback to invoke after opening a file -* @returns {void} -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* var open = require( '@stdlib/fs-open' ); -* -* function onOpen( error, fd ) { -* if ( error ) { -* throw error; -* } -* closeSync( fd ); -* } -* open( __filename, onOpen ); -*/ -function open( path, flags, mode, clbk ) { // eslint-disable-line stdlib/no-redeclare - var nargs = arguments.length; - if ( nargs === 2 ) { - return op( path, defaults.flags, defaults.mode, flags ); - } - if ( nargs === 3 ) { - return op( path, flags, defaults.mode, mode ); - } - op( path, flags, mode, clbk ); -} - - -// EXPORTS // - -module.exports = open; diff --git a/lib/sync.js b/lib/sync.js deleted file mode 100644 index d8d2e00..0000000 --- a/lib/sync.js +++ /dev/null @@ -1,68 +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. -*/ - -'use strict'; - -// MODULES // - -var open = require( 'fs' ).openSync; // eslint-disable-line node/no-sync, stdlib/no-redeclare -var defaults = require( './defaults.json' ); - - -// MAIN // - -/** -* Synchronously opens a file. -* -* @param {(string|Buffer)} path - file path -* @param {(string|number)} [flags='r'] - file system flags -* @param {integer} [mode=0o666] - file mode -* @returns {(integer|Error)} file descriptor or an error -* -* @example -* var closeSync = require( '@stdlib/fs-close' ).sync; -* -* var fd = openSync( __filename ); -* if ( fd instanceof Error ) { -* throw fd; -* } -* closeSync( fd ); -*/ -function openSync( path, flags, mode ) { - var nargs; - var fd; - - nargs = arguments.length; - try { - if ( nargs === 1 ) { - fd = open( path, defaults.flags, defaults.mode ); - } else if ( nargs === 2 ) { - fd = open( path, flags, defaults.mode ); - } else { - fd = open( path, flags, mode ); - } - } catch ( err ) { - return err; - } - return fd; -} - - -// EXPORTS // - -module.exports = openSync; diff --git a/package.json b/package.json index e20fa42..c2272c8 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Open a file.", "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/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/assert-is-browser": "^0.2.2", - "@stdlib/assert-is-error": "^0.2.2", - "@stdlib/assert-is-nonnegative-integer": "^0.2.2", - "@stdlib/fs-close": "^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", "stdfs", @@ -82,4 +30,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..34bd866 --- /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 3c47135..0000000 --- a/test/test.js +++ /dev/null @@ -1,38 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var open = require( './../lib' ); // eslint-disable-line stdlib/no-redeclare - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is a function to open a file synchronously', function test( t ) { - t.equal( typeof open.sync, 'function', 'has method' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 33b938f..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,110 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/main.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - open( __filename, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - open( __filename, 'r+', onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - open( __filename, 'r+', 438, onOpen ); - - function onOpen( error, fd ) { - if ( error ) { - t.fail( error.message ); - } - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - open( 'beepboopbapbop', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - open( 'beepboopbapbop', 'r+', 438, onOpen ); - - function onOpen( error ) { - t.equal( error instanceof Error, true, error.message ); - t.end(); - } -}); diff --git a/test/test.sync.js b/test/test.sync.js deleted file mode 100644 index 56d7b23..0000000 --- a/test/test.sync.js +++ /dev/null @@ -1,83 +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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert-is-browser' ); -var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; -var closeSync = require( '@stdlib/fs-close' ).sync; -var open = require( './../lib/sync.js' ); // eslint-disable-line stdlib/no-redeclare - - -// VARIABLES // - -// Don't run tests in the browser...for now... -var opts = { - 'skip': IS_BROWSER // FIXME -}; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof open, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function opens a file', opts, function test( t ) { - var fd = open( __filename ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags)', opts, function test( t ) { - var fd = open( __filename, 'r+' ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'the function opens a file (flags+mode)', opts, function test( t ) { - var fd = open( __filename, 'r+', 438 ); - t.equal( isNonNegativeInteger( fd ), true, 'returns a file descriptor' ); - closeSync( fd ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error', opts, function test( t ) { - var fd = open( 'beepboopbapbop' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+' ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -}); - -tape( 'if the function encounters an error, the function returns the error (flags+mode)', opts, function test( t ) { - var fd = open( 'beepboopbapbop', 'r+', 438 ); - t.equal( fd instanceof Error, true, 'returns an error' ); - t.end(); -});